/*
Replication Code- Anlaysis File

Bleiberg, J., Harbatkin, E., Brunner, E., Kraft, & M., Springer, M., (Forthcoming). The Effect of Teacher Taking Teacher Evaluation to Scale: The Effect of State Reforms on Achievement and Attainment. (Journal of Political Economy Microeconomics.
*/

//Change Directory to Folder that Contains Data and Create Output Folder
//cd !!! Change to directory that contains data
graph set window fontface "Times New Roman"

********************************************************************************
********************************************************************************
**# TABLE I- Analytic Sample Descriptive Characteristics
********************************************************************************
********************************************************************************
//Achievement
use "Data/achievement_data.dta", clear

putexcel set "Output/table_1_analytic_sample_descriptive_characteristics.xlsx", modify

qui sum cs_mn_all if subject=="rla" & st_trim_sample==1 & st_ela_smp==1
	putexcel C5=matrix(r(mean))
	putexcel D5=matrix(r(sd))
	putexcel E5=matrix(r(N))
qui sum cs_mn_all if subject=="mth" & st_trim_sample==1 & st_math_smp==1
	putexcel C6=matrix(r(mean))
	putexcel D6=matrix(r(sd))
	putexcel E6=matrix(r(N))
	
//Attainment 	
preserve
use "Data/attainment_data.dta", clear
qui sum hs_no_ged_a20 if hs_grad_a20_smp==1 & trim_sample==0
	putexcel C7=matrix(r(mean))
	putexcel D7=matrix(r(sd))
	putexcel E7=matrix(r(N))
restore

preserve
use "Data/attainment_data.dta", clear
qui sum enroll_pct_a20 if enroll_pct_a22_smp==1 & trim_sample==0
	putexcel C8=matrix(r(mean))
	putexcel D8=matrix(r(sd))
	putexcel E8=matrix(r(N))
restore	
	
gen gdp_100k=gdp/1000000

qui tabstat perwht perblk perhsp perind perasn totenrl urban gdp_100k povertyall unempall ///
	stud_tch_ratio ppe_inst if st_math_smp==1  & st_trim_sample==1, save stat(mean sd n)
	mat descrip=r(StatTotal)'
	putexcel C9=matrix(descrip)
	
//Adding Row and Label Titles
putexcel B4="Characteristic"
putexcel C4="Mean"
putexcel D4="SD"
putexcel E4="N"
putexcel B5="ELA Score"
putexcel B6="Math Score"
putexcel B7="High School Graduation"
putexcel B8="College Enrollment"
putexcel B9="Percent White"
putexcel B10="Percent Black"
putexcel B11="Percent Hispanic/Latinx"
putexcel B12="Percent Native American"
putexcel B13="Percent Asian"
putexcel B14="Total Enrollment (Ks)"
putexcel B15="Urban/City"
putexcel B16="GDP Chained $s (100Ks)"
putexcel B17="Poverty Index"
putexcel B18="Unemployment Rate"
putexcel B19="Student Teacher Ratio"
putexcel B20="Per-Pupil Expenditures in Ks"

********************************************************************************
********************************************************************************
**# TABLE II- Effect of Teacher Evaluation: Difference-in-Differences Models
********************************************************************************
********************************************************************************
//Achievement
use "Data/achievement_data.dta", clear

gen p1=gen_st_tch_eval_imp
replace p1=0 if gen_st_tch_rel_9==1

gen p2=gen_st_tch_eval_imp
replace p2=0 if gen_st_tch_rel_9==1
replace p2=0 if gen_st_tch_rel_10==1

gen post_9_10=0
replace post_9_10=1 if gen_st_tch_rel_9==1 
replace post_9_10=1 if gen_st_tch_rel_10==1 

//Model 1
qui reghdfe cs_mn_all gen_st_tch_eval_imp  if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store twfe_st_math

qui reghdfe cs_mn_all gen_st_tch_eval_imp  if subject=="rla" & st_trim_sample==1 & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store twfe_st_ela

//Model 2
local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l


qui reghdfe cs_mn_all gen_st_tch_eval_imp `cov' `ses_cov' `ach'  if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store twfe_pach_st_math
di r(table)[6,1] //Upper CI


qui reghdfe cs_mn_all gen_st_tch_eval_imp `cov' `ses_cov' `ach'  if subject=="rla" & st_trim_sample==1  & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store twfe_pach_st_ela
di r(table)[6,1] //Upper CI

//Model 3
local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

qui reghdfe cs_mn_all p2 post_9_10 `cov' `ses_cov' `ach'  if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store math_p3
di r(table)[6,1] //Upper CI

qui reghdfe cs_mn_all p2 post_9_10 `cov' `ses_cov' `ach'  if subject=="rla" & st_trim_sample==1  & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store ela_p3
di r(table)[6,1] //Upper CI

//Attainment
use "Data/attainment_data.dta", clear

gen post_0_1=gen_st_tch_eval_imp
replace post_0_1=0 if gen_st_tch_rel_10==1
replace post_0_1=0 if gen_st_tch_rel_11==1

gen post_2_plus=0
replace post_2_plus=1 if gen_st_tch_rel_10==1 
replace post_2_plus=1 if gen_st_tch_rel_11==1 

gen post_0_3=gen_st_tch_eval_imp
replace post_0_3=0 if gen_st_tch_rel_10==1
replace post_0_3=0 if gen_st_tch_rel_11==1
replace post_0_3=0 if gen_st_tch_rel_12==1
replace post_0_3=0 if gen_st_tch_rel_13==1

gen post_4_plus=0
replace post_4_plus=1 if gen_st_tch_rel_10==1 
replace post_4_plus=1 if gen_st_tch_rel_11==1 
replace post_4_plus=1 if gen_st_tch_rel_12==1
replace post_4_plus=1 if gen_st_tch_rel_13==1

//Model 1
qui reghdfe hs_no_ged_a20 gen_st_tch_eval_imp if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store hs_no_ged_a20_did
qui reghdfe enroll_pct_a22 gen_st_tch_eval_imp if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year) cluster(fips)
	estimate store enroll_pct_a22_did	

//Model 2
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l hs_no_ged_a20_base_l ela_sd_naep_l math_sd_naep_l

qui reghdfe hs_no_ged_a20 gen_st_tch_eval_imp `covars' if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store hs_no_ged_a20_did_covar
di r(table)[6,1] //Upper CI

local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l enroll_pct_a22_base_l ela_sd_naep_l math_sd_naep_l

qui reghdfe enroll_pct_a22 gen_st_tch_eval_imp `covars' if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year) cluster(fips)
	estimate store enroll_pct_a22_did_covar
di r(table)[6,1] //Upper CI

//Model 3
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l hs_no_ged_a20_base_l ela_sd_naep_l math_sd_naep_l

reghdfe hs_no_ged_a20 post_0_1 post_2_plus `covars' if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store hs_grad_p3
di r(table)[6,1] //Upper CI

local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l enroll_pct_a22_base_l ela_sd_naep_l math_sd_naep_l

reghdfe enroll_pct_a22 post_0_3 post_4_plus `covars' if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year) cluster(fips)
	estimate store enroll_pct_a22_hs_grad_p3
di r(table)[6,1] //Upper CI

//Table
esttab twfe_st_math twfe_pach_st_math math_p3 twfe_st_ela twfe_pach_st_ela ela_p3 ///
	hs_no_ged_a20_did hs_no_ged_a20_did_covar hs_grad_p3 enroll_pct_a22_did enroll_pct_a22_did_covar enroll_pct_a22_hs_grad_p3 ///
	using "Output/table_2_teacher_eval_effect_did.csv", ///
	label ///
	nodepvars ///
	b(4) ///
	t(4) ///
	sfmt (4 0 0 0) ///
	replace  ///
	se(4) ///
	nomtitle ///
	nonote ///
	nogap ///
	stat(N, label("n") fmt(a3)) ///
	coeflabel(gen_st_tch_eval_imp "Tch Eval" ///
	p2 "Tch Eval 2 to 5" ///
	post_9_10 "Tch Eval 0 to 1" ///
	post_0_3 "Tch Eval  0 to 3 " ///
	post_4_plus "Tch Eval 4 to 8" ///
	post_0_1 "Tch Eval  0 to 1" ///
	post_2_plus "Tch Eval 2 to 8") ///
	keep(gen_st_tch_eval_imp p2 post_9_10 post_0_3 post_4_plus post_0_1 post_2_plus)

********************************************************************************
********************************************************************************
**# TABLE III- Regressing Continuous Teacher Quality Index on Outcomes
********************************************************************************
********************************************************************************
//Achievement
use "Data/achievement_data.dta", clear

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

qui reghdfe cs_mn_all i.gen_st_tch_eval_imp##c.index  if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store index_st_math
lincom 1.gen_st_tch_eval_imp+1.gen_st_tch_eval_imp#c.index

qui reghdfe cs_mn_all i.gen_st_tch_eval_imp##c.index `cov' `ses_cov' `ach'  if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store index_pach_st_math
lincom 1.gen_st_tch_eval_imp+1.gen_st_tch_eval_imp#c.index

qui reghdfe cs_mn_all i.gen_st_tch_eval_imp##c.index  if subject=="rla" & st_trim_sample==1 & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store index_st_ela
lincom 1.gen_st_tch_eval_imp+1.gen_st_tch_eval_imp#c.index

qui reghdfe cs_mn_all i.gen_st_tch_eval_imp##c.index `cov' `ses_cov' `ach'  if subject=="rla" & st_trim_sample==1  & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store index_pach_st_ela
lincom 1.gen_st_tch_eval_imp+1.gen_st_tch_eval_imp#c.index //Overall significant
lincom 1.gen_st_tch_eval_imp+(2*1.gen_st_tch_eval_imp#c.index) //Effect for two components

//Attainment
use "Data/attainment_data.dta", clear
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l hs_no_ged_a20_base_l ela_sd_naep_l math_sd_naep_l
reghdfe hs_no_ged_a20 i.gen_st_tch_eval_imp##c.index if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store hs_no_ged_a20_het_ncov
reghdfe hs_no_ged_a20 i.gen_st_tch_eval_imp##c.index `covars' if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store hs_no_ged_a20_het_cov

local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l enroll_pct_a22_base_l ela_sd_naep_l math_sd_naep_l
reghdfe enroll_pct_a22 i.gen_st_tch_eval_imp##c.index if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store enroll_pct_a22_het_ncov
reghdfe enroll_pct_a22 i.gen_st_tch_eval_imp##c.index `covars' if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store enroll_pct_a22_het_cov

esttab index_st_math index_pach_st_math index_st_ela index_pach_st_ela hs_no_ged_a20_het_ncov hs_no_ged_a20_het_cov enroll_pct_a22_het_ncov enroll_pct_a22_het_cov ///
	using "Output/table_3_continuous_teacher_quality_index.csv", ///
	label ///
	nodepvars ///
	b(4) ///
	t(4) ///
	sfmt (4 0 0 0) ///
	replace  ///
	se(4) ///
	nomtitle ///
	nonote ///
	nogap ///
	stat(N, label("n") fmt(a3)) ///
	coeflabels(1.gen_st_tch_eval_imp "Teacher Evaluation" 1.gen_st_tch_eval_imp#c.index "Teacher Evaluation X Index") ///
	keep(1.gen_st_tch_eval_imp 1.gen_st_tch_eval_imp#c.index)
	

********************************************************************************
********************************************************************************
**# TABLE IV- Effect of Teacher Evaluation on Working Conditions
********************************************************************************
********************************************************************************
/*
Created using SASS/NTPS Restricted Data. Regression analysis code included for reference

//Sample Restriction
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l ela_sd_naep_l math_sd_naep_l
reghdfe sd_score gen_st_tch_eval_imp `covars', absorb(fips year)
	estimate store sass_sample
	gen sass_sample=e(sample)

local vars high_pay_hcat job_security_hcat job_satisfaction_hcat mat_avail_hcat content_hcat technique_hcat

foreach i of local vars{
gen `i'_hcat=(inlist(`i',1))
	
reghdfe  `i' tch_eval_imp [aw=tfnlwgt], absorb(fips_num year) cluster(fips_num)
}
*/

********************************************************************************
********************************************************************************
**# FIGURE I. Teacher Evaluation Implementation
********************************************************************************
********************************************************************************
//State Implementation Map
shp2dta using "Data/cb_2018_us_state_500k/cb_2018_us_state_500k", ///
	database("Data/usstates.dta") coordinates("Data/us_coordinates") genid(id) replace
use "Data/usstates.dta", clear

quietly destring STATEFP, generate(fips)
drop if inrange(fips,57,1000)
preserve
import excel "Data/treatment_data.xlsx", sheet("st_data") cellrange(A1:C52) firstrow clear
rename state NAME
tempfile st_treat
save "`st_treat'"
restore
merge 1:1 NAME using "`st_treat'", gen(state_map_merge)
keep if state_map_merge==3
recode  gen_st_tch_eval_imp_yr gen_st_tch_eval_imp_yr (.=0)

label define state_reform_label 0 "No Reform", replace
label values gen_st_tch_eval_imp_yr state_reform_label

l fips id  if fips == 2 | fips == 15
save "Data/usstates2.dta",replace

use "Data/us_coordinates.dta",clear
gen order = _n
drop if _X < -165 & _X != . &  _ID == 43
replace _X = _X  + 55  if  _X != .  &  _ID == 43
replace _Y = _Y  + 4  if _Y != .  &  _ID == 43

replace _X = _X*.4  -55 if  _X !=  . &  _ID == 28
replace _Y = _Y*.4  + 1 if _Y != .  & _ID == 28
drop if _X > -10 & _X != . & _ID == 28
sort order 
sort _ID
drop order
save "Data/us_coordinates2.dta",replace
use "Data/usstates2.dta",clear
spmap gen_st_tch_eval_imp_yr using "Data/us_coordinates2.dta"  , id(id) fcolor(Greys) ///
clmethod(unique) name(st_1, replace) legend(pos(4))
graph export "Output/figure_2_panel_a_state_implementation_map.pdf", as(pdf) replace

//Histogram of Teacher Evaluation Reform Quality Index
use "Data/achievement_data.dta", clear
collapse (max) index, by(stateabb)
drop if stateabb==""

histogram index, freq discrete yline(5 10, lp(solid) lc(black) lwid(vthin) )  ///
			graphregion(color(white)) bcolor(black) fcolor(gs10) ///
	xlabel(0(1)10) xtitle("Count of Teacher Evaluation Policy Components")
	graph export "Output/figure_2_panel_b_histogram_tch_eval_reform_qality.pdf", as(pdf) replace
	
********************************************************************************
********************************************************************************
**# FIGURE II- Event Study: Effects on Achievement and Attainment
********************************************************************************
********************************************************************************
//Achievement
use "Data/achievement_data.dta", clear

local st_event_dummies gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_8

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

qui reghdfe cs_mn_all `st_event_dummies' `cov' `ses_cov' `ach'  if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store ev_pach_st_math
di r(table)[6,6] //Year 0-Post 1 Upper CI
di r(table)[6,11] //Year 5-Post 6 Upper CI

coefplot (ev_pach_st_math, mlcolor(black) mfcolor(black)), ///
vert rename(gen_st_tch_rel_3="-6" gen_st_tch_rel_4="-5" gen_st_tch_rel_5="-4" gen_st_tch_rel_6="-3" ///
gen_st_tch_rel_7="-2" gen_st_tch_rel_8="-1" gen_st_tch_rel_9="0" gen_st_tch_rel_10="1" ///
gen_st_tch_rel_11="2" gen_st_tch_rel_12="3" gen_st_tch_rel_13="4" gen_st_tch_rel_14="5") ///
order("-6" "-5" "-4" "-3" "-2" "-1" "0" "1" "2" "3" "4" "5") ///
xtitle("State General Teacher Eval Implemented (Year)") xline(6, lp(solid) lcolor(gs7*.5)) xlabel(, labsize(small)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) lcol(black)) ///
ytitle("Math Score SD") yscale(range(-.1 .1)) ylabel(-.1(.02).1, labsize(small)) levels(95) ///
yline(0, lp(solid) lc(black)) ///
yline(-0.10 -0.08 -0.06 -0.04 -0.02 0.02 0.04 0.06 0.08 0.10, lp(solid) lc(gs12) lwid(vthin)) ///
keep(gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 ///
gen_st_tch_rel_8 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14) ///
scheme(s2color)
graph export "Output/figure_2_event_study_panel_achievement_math.pdf", as(pdf) replace


qui reghdfe cs_mn_all `st_event_dummies' `cov' `ses_cov' `ach'  if subject=="rla" & st_trim_sample==1 & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store ev_pach_st_ela
di r(table)[6,6] //Year 0-Post 1 Upper CI
di r(table)[6,11] //Year 5-Post 6 Upper CI

coefplot (ev_pach_st_ela, mlcolor(black) mfcolor(black)), ///
vert rename(gen_st_tch_rel_3="-6" gen_st_tch_rel_4="-5" gen_st_tch_rel_5="-4" gen_st_tch_rel_6="-3" ///
gen_st_tch_rel_7="-2" gen_st_tch_rel_8="-1" gen_st_tch_rel_9="0" gen_st_tch_rel_10="1" ///
gen_st_tch_rel_11="2" gen_st_tch_rel_12="3" gen_st_tch_rel_13="4" gen_st_tch_rel_14="5") ///
order("-6" "-5" "-4" "-3" "-2" "-1" "0" "1" "2" "3" "4" "5") ///
xtitle("State General Teacher Eval Implemented (Year)") xline(6, lp(solid) lcolor(gs7*.5)) xlabel(, labsize(small)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) lcol(black)) ///
ytitle("ELA Score SD") yscale(range(-.1 .1)) ylabel(-.1(.02).1, labsize(small)) levels(95) ///
yline(0, lp(solid) lc(black)) ///
yline(-0.10 -0.08 -0.06 -0.04 -0.02 0.02 0.04 0.06 0.08 0.10, lp(solid) lc(gs12) lwid(vthin)) ///
keep(gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 ///
gen_st_tch_rel_8 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14) ///
scheme(s2color)
graph export "Output/figure_2_event_study_panel_achievement_ela.pdf", as(pdf) replace

//Attainment
use "Data/attainment_data.dta", clear

local event_dummies gen_st_tch_rel_5-gen_st_tch_rel_8 gen_st_tch_rel_10-gen_st_tch_rel_18 gen_st_tch_rel_9 ref
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l hs_no_ged_a20_base_l ela_sd_naep_l math_sd_naep_l
qui reghdfe hs_no_ged_a20 `event_dummies' `covars' ///
if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store hs_no_ged_a20_event_cov

coefplot (hs_no_ged_a20_event_cov, mlcolor(black) mfcolor(black)), ///
vert rename(gen_st_tch_rel_5="-5" ///
			gen_st_tch_rel_6="-4" ///
			gen_st_tch_rel_7="-3" ///
			gen_st_tch_rel_8="-2" ///
			gen_st_tch_rel_9="-1" ///
			gen_st_tch_rel_10="0" ///
			gen_st_tch_rel_11="1" ///
			gen_st_tch_rel_12="2" ///
			gen_st_tch_rel_13="3" ///
			gen_st_tch_rel_14="4" ///
			gen_st_tch_rel_15="5" ///
			gen_st_tch_rel_16="6" ///
			gen_st_tch_rel_17="7" ///
			gen_st_tch_rel_18="8") ///
order("-5" "-4" "-3" "-2" "-1" "0" "1" "2" "3" "4" "5" "6" "7" "8") ///
xtitle("State Teacher Eval Implemented (Year)") xline(5, lp(solid) lcolor(gs7*.5)) ///
ytitle("% HS Graduates") yscale(range(-5 5)) levels(95) /// ///
ylabel(-8 "8%" -7 "7%" -6 "6%" -5 "-5%" -4 "-4%" -3 "-3%" -2 "-2%" -1 "-1%" 0 "0%"  1 "1%" 2 "2%" 3 "3%" 4 "4%" 5 "5%" 6 "6%" 7 "7%" 8 "8%", ///
angle(45) labsize(small) labc(black)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) lcol(black)) ///
yline(0, lp(solid) lc(black)) ///
yline(-8 -7 -6 -5 -4 -3 -2 -1 1 2 3 4 5 6 7 8, lp(solid) lc(gs12) lwid(vthin)) ///
keep(gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_8 ///
		   gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 ///
		   gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_15 gen_st_tch_rel_16 gen_st_tch_rel_17 gen_st_tch_rel_18) ///
scheme(s2color)
graph export "Output/figure_2_event_study_panel_attainment_hs_grad.pdf", as(pdf) replace


local event_dummies gen_st_tch_rel_5-gen_st_tch_rel_8 gen_st_tch_rel_10-gen_st_tch_rel_18 gen_st_tch_rel_9 ref
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l enroll_pct_a22_base_l ela_sd_naep_l math_sd_naep_l
reghdfe enroll_pct_a22 `event_dummies' `covars' ///
if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year) cluster(fips)
	estimate store enroll_pct_a22_event_cov

coefplot (enroll_pct_a22_event_cov, mlcolor(black) mfcolor(black)), ///
vert rename(gen_st_tch_rel_5="-5" ///
			gen_st_tch_rel_6="-4" ///
			gen_st_tch_rel_7="-3" ///
			gen_st_tch_rel_8="-2" ///
			gen_st_tch_rel_9="-1" ///
			gen_st_tch_rel_10="0" ///
			gen_st_tch_rel_11="1" ///
			gen_st_tch_rel_12="2" ///
			gen_st_tch_rel_13="3" ///
			gen_st_tch_rel_14="4" ///
			gen_st_tch_rel_15="5" ///
			gen_st_tch_rel_16="6" ///
			gen_st_tch_rel_17="7" ///
			gen_st_tch_rel_18="8") ///
order("-5" "-4" "-3" "-2" "-1" "0" "1" "2" "3" "4" "5" "6" "7" "8") ///
xtitle("State Teacher Eval Implemented (Year)") xline(5, lp(solid) lcolor(gs7*.5)) ///
ytitle("% College Enrollment") yscale(range(-5 5)) levels(95) /// ///
ylabel(-8 "8%" -7 "7%" -6 "6%" -5 "-5%" -4 "-4%" -3 "-3%" -2 "-2%" -1 "-1%" 0 "0%"  1 "1%" 2 "2%" 3 "3%" 4 "4%" 5 "5%" 6 "6%" 7 "7%" 8 "8%", ///
angle(45) labsize(small) labc(black)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) lcol(black)) ///
yline(0, lp(solid) lc(black)) ///
yline(-8 -7 -6 -5 -4 -3 -2 -1 1 2 3 4 5 6 7 8, lp(solid) lc(gs12) lwid(vthin)) ///
keep(gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_8 ///
		   gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 ///
		   gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_15 gen_st_tch_rel_16 gen_st_tch_rel_17 gen_st_tch_rel_18) ///
scheme(s2color)
graph export "Output/figure_2_event_study_panel_attainment_col_enrl.pdf", as(pdf) replace

********************************************************************************
********************************************************************************
**# FIGURE III- Event Study: Heterogeneity by Exemplar Evaluation Systems
********************************************************************************
********************************************************************************
use "Data/achievement_data.dta", clear

keep if inrange(gen_st_tch_rel,-4,4)
drop if fips==11
gen st_trim_sample_nctq=st_trim_sample

//Math
local nctq_rel  nctq_rel_4 nctq_rel_5 nctq_rel_6 nctq_rel_7 ///
nctq_rel_9 nctq_rel_10 nctq_rel_11 nctq_rel_12 nctq_rel_8
local no_nctq_rel no_nctq_rel_4 no_nctq_rel_5 no_nctq_rel_6 no_nctq_rel_7 ///
	no_nctq_rel_9 no_nctq_rel_10 no_nctq_rel_11 no_nctq_rel_12 no_nctq_rel_8

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

reghdfe cs_mn_all  `no_nctq_rel' `nctq_rel' `cov' `ses_cov' `ach' if subject=="mth" & st_trim_sample_nctq==1 & st_math_smp==1, absorb(leaid year grade subject) cluster(fips)
estimate store event_mth

estimate restore event_mth
xlincom (rel_4=no_nctq_rel_4) ///
		(rel_5=no_nctq_rel_5) ///
		(rel_6=no_nctq_rel_6) ///
		(rel_7=no_nctq_rel_7) ///
		(rel_8=no_nctq_rel_8) ///
		(rel_9=no_nctq_rel_9) ///
		(rel_10=no_nctq_rel_10) ///
		(rel_11=no_nctq_rel_11) ///
		(rel_12=no_nctq_rel_12), post
estimate store event_no_mth_nctq

estimate restore event_mth
xlincom (rel_4=nctq_rel_4) ///
		(rel_5=nctq_rel_5) ///
		(rel_6=nctq_rel_6) ///
		(rel_7=nctq_rel_7) ///
		(rel_8=nctq_rel_8) ///
		(rel_9=nctq_rel_9) ///
		(rel_10=nctq_rel_10) ///
		(rel_11=nctq_rel_11) ///
		(rel_12=nctq_rel_12), post
estimate store event_nctq_mth

coefplot (event_no_mth_nctq,  msymbol(O) mlcolor(black) mfcolor(black) ciopts(recast(rcap) color(black)) ) ///
		 (event_nctq_mth, msymbol(O) mlcolor(gs7*.5) mfcolor(gs7*.5) ciopts(recast(rcap) color(gs7*.5))) ///
, vert ///
coeflabel(rel_4="-5" rel_5="-4" rel_6="-3" rel_7="-2" rel_8="-1" rel_9="0" rel_10="1" rel_11="2" rel_12="3") ///
xtitle("Years Relative to Teacher Evaluation") xline(5, lp(solid) lcolor(gs3)) xlabel(, labsize(small)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) lcol(black)) ///
ytitle("Math Effect SD") yscale(range(-.2 .2)) ylabel(-.20(.04).24, labsize(small)) levels(95) ///
yline(-0.20 -0.16 -0.12 -0.08 -0.04 0.04 0.08 0.12 0.16 0.20 0.24, lp(solid) lc(gs12) lwid(vthin)) ///
yline(0, lp(dash) lc(black)) ///
legend(order(2 "Non-Exemplar Eval" 4 "Exemplar Tch Eval") pos(6) row(1))

graph export "Output/figure_3_panel_a_event_study_exemplar_districts_math.pdf", as(pdf) replace

//ELA
local nctq_rel nctq_rel_4 nctq_rel_5 nctq_rel_6 nctq_rel_7 ///
nctq_rel_9 nctq_rel_10 nctq_rel_11 nctq_rel_12 nctq_rel_8
local no_nctq_rel no_nctq_rel_4 no_nctq_rel_5 no_nctq_rel_6 no_nctq_rel_7 ///
	no_nctq_rel_9 no_nctq_rel_10 no_nctq_rel_11 no_nctq_rel_12 no_nctq_rel_8

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

reghdfe cs_mn_all  `no_nctq_rel' `nctq_rel' `cov' `ses_cov' `ach' if subject=="rla" & st_trim_sample_nctq==1  & st_ela_smp==1, absorb(leaid year grade subject) cluster(fips)
estimate store event_ela

estimate restore event_ela
xlincom (rel_4=no_nctq_rel_4) ///
		(rel_5=no_nctq_rel_5) ///
		(rel_6=no_nctq_rel_6) ///
		(rel_7=no_nctq_rel_7) ///
		(rel_8=no_nctq_rel_8) ///
		(rel_9=no_nctq_rel_9) ///
		(rel_10=no_nctq_rel_10) ///
		(rel_11=no_nctq_rel_11) ///
		(rel_12=no_nctq_rel_12), post
estimate store event_no_ela_nctq

estimate restore event_ela
xlincom (rel_4=nctq_rel_4) ///
		(rel_5=nctq_rel_5) ///
		(rel_6=nctq_rel_6) ///
		(rel_7=nctq_rel_7) ///
		(rel_8=nctq_rel_8) ///
		(rel_9=nctq_rel_9) ///
		(rel_10=nctq_rel_10) ///
		(rel_11=nctq_rel_11) ///
		(rel_12=nctq_rel_12), post
estimate store event_ela_nctq

coefplot (event_no_ela_nctq,  msymbol(O) mlcolor(black) mfcolor(black) ciopts(recast(rcap) color(black)) ) ///
		 (event_ela_nctq, msymbol(O) mlcolor(gs7*.5) mfcolor(gs7*.5) ciopts(recast(rcap) color(gs7*.5))) ///
, vert ///
coeflabel(rel_4="-5" rel_5="-4" rel_6="-3" rel_7="-2" rel_8="-1" rel_9="0" rel_10="1" rel_11="2" rel_12="3") ///
xtitle("Years Relative to Teacher Evaluation") xline(5, lp(solid) lcolor(gs3)) xlabel(, labsize(small)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) lcol(black)) ///
ytitle("ELA Effect SD") yscale(range(-.2 .2)) ylabel(-.20(.04).24, labsize(small)) levels(95) ///
yline(-0.20 -0.16 -0.12 -0.08 -0.04 0.04 0.08 0.12 0.16 0.20 0.24, lp(solid) lc(gs12) lwid(vthin)) ///
yline(0, lp(dash) lc(black)) ///
legend(order(2 "Non-Exemplar Eval" 4 "Exemplar Tch Eval") pos(6) row(1))

graph export "Output/figure_3_panel_a_event_study_exemplar_districts_ela.pdf", as(pdf) replace

********************************************************************************
********************************************************************************
**# FIGURE IV-Event Study: Heterogeneity by Index
********************************************************************************
********************************************************************************
use "Data/achievement_data.dta", clear

local st_event_dummies gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_8

local st_event_dummies_all gen_st_tch_rel_3_h7 gen_st_tch_rel_4_h7 gen_st_tch_rel_5_h7 gen_st_tch_rel_6_h7 gen_st_tch_rel_7_h7 gen_st_tch_rel_9_h7 gen_st_tch_rel_10_h7 gen_st_tch_rel_11_h7 gen_st_tch_rel_12_h7 gen_st_tch_rel_13_h7 gen_st_tch_rel_14_h7 gen_st_tch_rel_8_h7

//All Covariates
local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

//Math
qui reghdfe cs_mn_all `st_event_dummies'  `st_event_dummies_all' ///
`cov' `ses_cov' `ach' ///
 if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store h7_ev_pch_math

estimate restore h7_ev_pch_math
xlincom (rel_3=gen_st_tch_rel_3) ///
		(rel_4=gen_st_tch_rel_4) ///
		(rel_5=gen_st_tch_rel_5) ///
		(rel_6=gen_st_tch_rel_6) ///
		(rel_7=gen_st_tch_rel_7) ///
		(rel_8=gen_st_tch_rel_8) ///
		(rel_9=gen_st_tch_rel_9) ///
		(rel_10=gen_st_tch_rel_10) ///
		(rel_11=gen_st_tch_rel_11) ///
		(rel_12=gen_st_tch_rel_12) ///
		(rel_13=gen_st_tch_rel_13) ///
		(rel_14=gen_st_tch_rel_14), post
estimate store ev_h7_low_math

estimate restore h7_ev_pch_math
xlincom (rel_3=gen_st_tch_rel_3+gen_st_tch_rel_3_h7) ///
		(rel_4=gen_st_tch_rel_4+gen_st_tch_rel_4_h7) ///
		(rel_5=gen_st_tch_rel_5+gen_st_tch_rel_5_h7) ///
		(rel_6=gen_st_tch_rel_6+gen_st_tch_rel_6_h7) ///
		(rel_7=gen_st_tch_rel_7+gen_st_tch_rel_7_h7) ///
		(rel_8=gen_st_tch_rel_8+gen_st_tch_rel_8_h7) ///
		(rel_9=gen_st_tch_rel_9+gen_st_tch_rel_9_h7) ///
		(rel_10=gen_st_tch_rel_10+gen_st_tch_rel_10_h7) ///
		(rel_11=gen_st_tch_rel_11+gen_st_tch_rel_11_h7) ///
		(rel_12=gen_st_tch_rel_12+gen_st_tch_rel_12_h7) ///
		(rel_13=gen_st_tch_rel_13+gen_st_tch_rel_13_h7) ///
		(rel_14=gen_st_tch_rel_14+gen_st_tch_rel_14_h7), post
estimate store ev_h7_high_math

//Creating Math Event Study
coefplot (ev_h7_low_math,  msymbol(O) mlcolor(black) mfcolor(black) ciopts(recast(rcap) color(black)) ) ///
		 (ev_h7_high_math, msymbol(O) mlcolor(gs7*.5) mfcolor(gs7*.5) ciopts(recast(rcap) color(gs7*.5))), vert ///
coeflabel(rel_3="-6" rel_4="-5" rel_5="-4" rel_6="-3" rel_7="-2" rel_8="-1" rel_9="0" rel_10="1" rel_11="2" rel_12="3" rel_13="4" rel_14="5") ///
xtitle("Years Relative to Teacher Evaluation") xline(5, lp(solid) lcolor(gs3)) xlabel(, labsize(small)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) lcol(black)) ///
ytitle("Math Effect SD") ///
yscale(range(-.1 .1)) ylabel(-.1(.02).1, labsize(small)) levels(95) ///
yline(-.1 -.08 -.06 -.04 -.02 0 .02 .04 .06 .08 .1, lp(solid) lc(gs12) lwid(vthin)) ///
yline(0, lp(dash) lc(black)) ///
legend(order(2 "Tch Eval" 4 "Tch Eval + (Index >6)") pos(6) row(1)) ///
scheme(s2color)
			 
graph export "Output/figure_4_panel_a_heterogeneity_by_index_math.pdf", as(pdf) replace

//ELA
local st_event_dummies gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_8

local st_event_dummies_all gen_st_tch_rel_3_h7 gen_st_tch_rel_4_h7 gen_st_tch_rel_5_h7 gen_st_tch_rel_6_h7 gen_st_tch_rel_7_h7 gen_st_tch_rel_9_h7 gen_st_tch_rel_10_h7 gen_st_tch_rel_11_h7 gen_st_tch_rel_12_h7 gen_st_tch_rel_13_h7 gen_st_tch_rel_14_h7 gen_st_tch_rel_8_h7

//All Covariates
local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

qui reghdfe cs_mn_all `st_event_dummies' `st_event_dummies_all' ///
`cov' `ses_cov' `ach' ///
 if subject=="rla" & st_trim_sample==1 & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store h7_ev_pch_ela

estimate restore h7_ev_pch_ela
xlincom (rel_3=gen_st_tch_rel_3) ///
		(rel_4=gen_st_tch_rel_4) ///
		(rel_5=gen_st_tch_rel_5) ///
		(rel_6=gen_st_tch_rel_6) ///
		(rel_7=gen_st_tch_rel_7) ///
		(rel_8=gen_st_tch_rel_8) ///
		(rel_9=gen_st_tch_rel_9) ///
		(rel_10=gen_st_tch_rel_10) ///
		(rel_11=gen_st_tch_rel_11) ///
		(rel_12=gen_st_tch_rel_12) ///
		(rel_13=gen_st_tch_rel_13) ///
		(rel_14=gen_st_tch_rel_14), post
estimate store ev_h7_low_ela

estimate restore h7_ev_pch_ela
xlincom (rel_3=gen_st_tch_rel_3+gen_st_tch_rel_3_h7) ///
		(rel_4=gen_st_tch_rel_4+gen_st_tch_rel_4_h7) ///
		(rel_5=gen_st_tch_rel_5+gen_st_tch_rel_5_h7) ///
		(rel_6=gen_st_tch_rel_6+gen_st_tch_rel_6_h7) ///
		(rel_7=gen_st_tch_rel_7+gen_st_tch_rel_7_h7) ///
		(rel_8=gen_st_tch_rel_8+gen_st_tch_rel_8_h7) ///
		(rel_9=gen_st_tch_rel_9+gen_st_tch_rel_9_h7) ///
		(rel_10=gen_st_tch_rel_10+gen_st_tch_rel_10_h7) ///
		(rel_11=gen_st_tch_rel_11+gen_st_tch_rel_11_h7) ///
		(rel_12=gen_st_tch_rel_12+gen_st_tch_rel_12_h7) ///
		(rel_13=gen_st_tch_rel_13+gen_st_tch_rel_13_h7) ///
		(rel_14=gen_st_tch_rel_14+gen_st_tch_rel_14_h7), post
estimate store ev_h7_high_ela

//Creating ELA Event Study
coefplot (ev_h7_low_ela,  msymbol(O) mlcolor(black) mfcolor(black) ciopts(recast(rcap) color(black)) ) ///
		 (ev_h7_high_ela, msymbol(O) mlcolor(gs7*.5) mfcolor(gs7*.5) ciopts(recast(rcap) color(gs7*.5))), vert ///
coeflabel(rel_3="-6" rel_4="-5" rel_5="-4" rel_6="-3" rel_7="-2" rel_8="-1" rel_9="0" rel_10="1" rel_11="2" rel_12="3" rel_13="4" rel_14="5") ///
xtitle("Years Relative to Teacher Evaluation") xline(5, lp(solid) lcolor(gs3)) xlabel(, labsize(small)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) lcol(black)) ///
ytitle("ELA Effect SD") ///
yscale(range(-.1 .1)) ylabel(-.1(.02).1, labsize(small)) levels(95) ///
yline(-.1 -.08 -.06 -.04 -.02 0 .02 .04 .06 .08 .1, lp(solid) lc(gs12) lwid(vthin)) ///
yline(0, lp(dash) lc(black)) ///
legend(order(2 "Tch Eval" 4 "Tch Eval + (Index >6)") pos(6) row(1)) ///
scheme(s2color)

graph export "Output/figure_4_panel_a_heterogeneity_by_index_ela.pdf", as(pdf) replace

********************************************************************************
********************************************************************************
**# FIGURE V-Event Study: Heterogeneity by System Design
********************************************************************************
********************************************************************************
use "Data/achievement_data.dta", clear
//Measurement
local st_event_dummies gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_8

local st_event_dummies_all gen_st_tch_rel_3_m_min1 gen_st_tch_rel_4_m_min1 gen_st_tch_rel_5_m_min1 gen_st_tch_rel_6_m_min1 gen_st_tch_rel_7_m_min1 gen_st_tch_rel_9_m_min1 gen_st_tch_rel_10_m_min1 gen_st_tch_rel_11_m_min1 gen_st_tch_rel_12_m_min1 gen_st_tch_rel_13_m_min1 gen_st_tch_rel_14_m_min1 gen_st_tch_rel_8_m_min1

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

qui reghdfe cs_mn_all `st_event_dummies'  `st_event_dummies_all' ///
`cov' `ses_cov' `ach' ///
 if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store m_min1_ev_pch_math

estimate restore m_min1_ev_pch_math
xlincom (rel_3=gen_st_tch_rel_3) ///
		(rel_4=gen_st_tch_rel_4) ///
		(rel_5=gen_st_tch_rel_5) ///
		(rel_6=gen_st_tch_rel_6) ///
		(rel_7=gen_st_tch_rel_7) ///
		(rel_8=gen_st_tch_rel_8) ///
		(rel_9=gen_st_tch_rel_9) ///
		(rel_10=gen_st_tch_rel_10) ///
		(rel_11=gen_st_tch_rel_11) ///
		(rel_12=gen_st_tch_rel_12) ///
		(rel_13=gen_st_tch_rel_13) ///
		(rel_14=gen_st_tch_rel_14), post
estimate store ev_m_min1_low_math

estimate restore m_min1_ev_pch_math
xlincom (rel_3=gen_st_tch_rel_4+gen_st_tch_rel_3_m_min1) ///
		(rel_4=gen_st_tch_rel_4+gen_st_tch_rel_4_m_min1) ///
		(rel_5=gen_st_tch_rel_5+gen_st_tch_rel_5_m_min1) ///
		(rel_6=gen_st_tch_rel_6+gen_st_tch_rel_6_m_min1) ///
		(rel_7=gen_st_tch_rel_7+gen_st_tch_rel_7_m_min1) ///
		(rel_8=gen_st_tch_rel_8+gen_st_tch_rel_8_m_min1) ///
		(rel_9=gen_st_tch_rel_9+gen_st_tch_rel_9_m_min1) ///
		(rel_10=gen_st_tch_rel_10+gen_st_tch_rel_10_m_min1) ///
		(rel_11=gen_st_tch_rel_11+gen_st_tch_rel_11_m_min1) ///
		(rel_12=gen_st_tch_rel_12+gen_st_tch_rel_12_m_min1) ///
		(rel_13=gen_st_tch_rel_13+gen_st_tch_rel_13_m_min1) ///
		(rel_14=gen_st_tch_rel_14+gen_st_tch_rel_14_m_min1), post
estimate store ev_m_min1_high_math

coefplot (ev_m_min1_low_math,  msymbol(O) mlcolor(black) mfcolor(black) ciopts(recast(rcap) color(black)) ) ///
		 (ev_m_min1_high_math, msymbol(O) mlcolor(gs7*.5) mfcolor(gs7*.5) ciopts(recast(rcap) color(gs7*.5))), vert ///
coeflabel(rel_3="-6" rel_4="-5" rel_5="-4" rel_6="-3" rel_7="-2" rel_8="-1" rel_9="0" rel_10="1" rel_11="2" rel_12="3" rel_13="4"  rel_14="5") ///
xtitle("Years Relative to Teacher Evaluation") xline(6, lp(solid) lcolor(gs3)) xlabel(, labsize(small)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) lcol(black)) ///
ytitle("Math Effect SD") ///
yscale(range(-.1 .1)) ylabel(-.1(.02).1, labsize(small)) levels(95) ///
yline(-.1 -.08 -.06 -.04 -.02 0 .02 .04 .06 .08 .1, lp(solid) lc(gs12) lwid(vthin)) ///
yline(0, lp(dash) lc(black)) scheme(s2color) ///
legend(order(2 "Tch Eval" 4 "Tch Eval + Measure"))
			 
graph export "Output/figure_5_panel_a_measurement_het_math.pdf", as(pdf) replace

local st_event_dummies gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_8

local st_event_dummies_all gen_st_tch_rel_3_m_min1 gen_st_tch_rel_4_m_min1 gen_st_tch_rel_5_m_min1 gen_st_tch_rel_6_m_min1 gen_st_tch_rel_7_m_min1 gen_st_tch_rel_9_m_min1 gen_st_tch_rel_10_m_min1 gen_st_tch_rel_11_m_min1 gen_st_tch_rel_12_m_min1 gen_st_tch_rel_13_m_min1 gen_st_tch_rel_14_m_min1 gen_st_tch_rel_8_m_min1

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

qui reghdfe cs_mn_all `st_event_dummies' `st_event_dummies_all' ///
`cov' `ses_cov' `ach' ///
 if subject=="rla" & st_trim_sample==1 & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store m_min1_ev_pch_ela

estimate restore m_min1_ev_pch_ela
xlincom (rel_3=gen_st_tch_rel_3) ///
		(rel_4=gen_st_tch_rel_4) ///
		(rel_5=gen_st_tch_rel_5) ///
		(rel_6=gen_st_tch_rel_6) ///
		(rel_7=gen_st_tch_rel_7) ///
		(rel_8=gen_st_tch_rel_8) ///
		(rel_9=gen_st_tch_rel_9) ///
		(rel_10=gen_st_tch_rel_10) ///
		(rel_11=gen_st_tch_rel_11) ///
		(rel_12=gen_st_tch_rel_12) ///
		(rel_13=gen_st_tch_rel_13) ///
		(rel_14=gen_st_tch_rel_14), post
estimate store ev_m_min1_low_ela

estimate restore m_min1_ev_pch_ela
xlincom (rel_3=gen_st_tch_rel_3+gen_st_tch_rel_3_m_min1) ///
		(rel_4=gen_st_tch_rel_4+gen_st_tch_rel_4_m_min1) ///
		(rel_5=gen_st_tch_rel_5+gen_st_tch_rel_5_m_min1) ///
		(rel_6=gen_st_tch_rel_6+gen_st_tch_rel_6_m_min1) ///
		(rel_7=gen_st_tch_rel_7+gen_st_tch_rel_7_m_min1) ///
		(rel_8=gen_st_tch_rel_8+gen_st_tch_rel_8_m_min1) ///
		(rel_9=gen_st_tch_rel_9+gen_st_tch_rel_9_m_min1) ///
		(rel_10=gen_st_tch_rel_10+gen_st_tch_rel_10_m_min1) ///
		(rel_11=gen_st_tch_rel_11+gen_st_tch_rel_11_m_min1) ///
		(rel_12=gen_st_tch_rel_12+gen_st_tch_rel_12_m_min1) ///
		(rel_13=gen_st_tch_rel_13+gen_st_tch_rel_13_m_min1) ///
		(rel_14=gen_st_tch_rel_14+gen_st_tch_rel_14_m_min1), post
estimate store ev_m_min1_high_ela

coefplot (ev_m_min1_low_ela,  msymbol(O) mlcolor(black) mfcolor(black) ciopts(recast(rcap) color(black)) ) ///
		 (ev_m_min1_high_ela, msymbol(O) mlcolor(gs7*.5) mfcolor(gs7*.5) ciopts(recast(rcap) color(gs7*.5))), vert ///
coeflabel(rel_3="-6" rel_4="-5" rel_5="-4" rel_6="-3" rel_7="-2" rel_8="-1" rel_9="0" rel_10="1" rel_11="2" rel_12="3" rel_13="4"  rel_14="5") ///
xtitle("Years Relative to Teacher Evaluation") xline(6, lp(solid) lcolor(gs3)) xlabel(, labsize(small)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) lcol(black)) ///
ytitle("ELA Effect SD") ///
yscale(range(-.1 .1)) ylabel(-.1(.02).1, labsize(small)) levels(95) ///
yline(-.1 -.08 -.06 -.04 -.02 0 .02 .04 .06 .08 .1, lp(solid) lc(gs12) lwid(vthin)) ///
yline(0, lp(dash) lc(black)) scheme(s2color) ///
legend(order(2 "Tch Eval" 4 "Tch Eval + Measure"))

graph export "Output/figure_5_panel_a_measurement_het_ela.pdf", as(pdf) replace

//Incentives/Accountability
local st_event_dummies gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_8

local st_event_dummies_all gen_st_tch_rel_3_ia_min1 gen_st_tch_rel_4_ia_min1 gen_st_tch_rel_5_ia_min1 gen_st_tch_rel_6_ia_min1 gen_st_tch_rel_7_ia_min1 gen_st_tch_rel_9_ia_min1 gen_st_tch_rel_10_ia_min1 gen_st_tch_rel_11_ia_min1 gen_st_tch_rel_12_ia_min1 gen_st_tch_rel_13_ia_min1 gen_st_tch_rel_14_ia_min1 gen_st_tch_rel_8_ia_min1

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

qui reghdfe cs_mn_all `st_event_dummies'  `st_event_dummies_all' ///
`cov' `ses_cov' `ach' ///
 if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store ia_min1_ev_pch_math

estimate restore ia_min1_ev_pch_math
xlincom (rel_3=gen_st_tch_rel_3) ///
		(rel_4=gen_st_tch_rel_4) ///
		(rel_5=gen_st_tch_rel_5) ///
		(rel_6=gen_st_tch_rel_6) ///
		(rel_7=gen_st_tch_rel_7) ///
		(rel_8=gen_st_tch_rel_8) ///
		(rel_9=gen_st_tch_rel_9) ///
		(rel_10=gen_st_tch_rel_10) ///
		(rel_11=gen_st_tch_rel_11) ///
		(rel_12=gen_st_tch_rel_12) ///
		(rel_13=gen_st_tch_rel_13) ///
		(rel_14=gen_st_tch_rel_14), post
estimate store ev_ia_min1_low_math

estimate restore ia_min1_ev_pch_math
xlincom (rel_3=gen_st_tch_rel_3+gen_st_tch_rel_3_ia_min1) ///
		(rel_4=gen_st_tch_rel_4+gen_st_tch_rel_4_ia_min1) ///
		(rel_5=gen_st_tch_rel_5+gen_st_tch_rel_5_ia_min1) ///
		(rel_6=gen_st_tch_rel_6+gen_st_tch_rel_6_ia_min1) ///
		(rel_7=gen_st_tch_rel_7+gen_st_tch_rel_7_ia_min1) ///
		(rel_8=gen_st_tch_rel_8+gen_st_tch_rel_8_ia_min1) ///
		(rel_9=gen_st_tch_rel_9+gen_st_tch_rel_9_ia_min1) ///
		(rel_10=gen_st_tch_rel_10+gen_st_tch_rel_10_ia_min1) ///
		(rel_11=gen_st_tch_rel_11+gen_st_tch_rel_11_ia_min1) ///
		(rel_12=gen_st_tch_rel_12+gen_st_tch_rel_12_ia_min1) ///
		(rel_13=gen_st_tch_rel_13+gen_st_tch_rel_13_ia_min1) ///
		(rel_14=gen_st_tch_rel_14+gen_st_tch_rel_14_ia_min1), post
estimate store ev_ia_min1_high_math

coefplot (ev_ia_min1_low_math,  msymbol(O) mlcolor(black) mfcolor(black) ciopts(recast(rcap) color(black)) ) ///
		 (ev_ia_min1_high_math, msymbol(O) mlcolor(gs7*.5) mfcolor(gs7*.5) ciopts(recast(rcap) color(gs7*.5))), vert ///
coeflabel(rel_3="-6" rel_4="-5" rel_5="-4" rel_6="-3" rel_7="-2" rel_8="-1" rel_9="0" rel_10="1" rel_11="2" rel_12="3" rel_13="4"  rel_14="5") ///
xtitle("Years Relative to Teacher Evaluation") xline(6, lp(solid) lcolor(gs3)) xlabel(, labsize(small)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) lcol(black)) ///
ytitle("Math Effect SD") ///
yscale(range(-.1 .1)) ylabel(-.1(.02).1, labsize(small)) levels(95) ///
yline(-.1 -.08 -.06 -.04 -.02 0 .02 .04 .06 .08 .1, lp(solid) lc(gs12) lwid(vthin)) ///
yline(0, lp(dash) lc(black)) scheme(s2color) ///
legend(order(2 "Tch Eval" 4 "Tch Eval + Incentives/Accountability"))
			 
graph export "Output/figure_5_panel_a_incent_acct_het_math.pdf", as(pdf) replace

local st_event_dummies gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_8

local st_event_dummies_all gen_st_tch_rel_3_ia_min1 gen_st_tch_rel_4_ia_min1 gen_st_tch_rel_5_ia_min1 gen_st_tch_rel_6_ia_min1 gen_st_tch_rel_7_ia_min1 gen_st_tch_rel_9_ia_min1 gen_st_tch_rel_10_ia_min1 gen_st_tch_rel_11_ia_min1 gen_st_tch_rel_12_ia_min1 gen_st_tch_rel_13_ia_min1 gen_st_tch_rel_14_ia_min1 gen_st_tch_rel_8_ia_min1

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

qui reghdfe cs_mn_all `st_event_dummies' `st_event_dummies_all' ///
`cov' `ses_cov' `ach' ///
 if subject=="rla" & st_trim_sample==1 & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store ia_min1_ev_pch_ela

estimate restore ia_min1_ev_pch_ela
xlincom (rel_3=gen_st_tch_rel_3) ///
		(rel_4=gen_st_tch_rel_4) ///
		(rel_5=gen_st_tch_rel_5) ///
		(rel_6=gen_st_tch_rel_6) ///
		(rel_7=gen_st_tch_rel_7) ///
		(rel_8=gen_st_tch_rel_8) ///
		(rel_9=gen_st_tch_rel_9) ///
		(rel_10=gen_st_tch_rel_10) ///
		(rel_11=gen_st_tch_rel_11) ///
		(rel_12=gen_st_tch_rel_12) ///
		(rel_13=gen_st_tch_rel_13) ///
		(rel_14=gen_st_tch_rel_14), post
estimate store ev_ia_min1_low_ela

estimate restore ia_min1_ev_pch_ela
xlincom (rel_3=gen_st_tch_rel_3+gen_st_tch_rel_3_ia_min1) ///
		(rel_4=gen_st_tch_rel_4+gen_st_tch_rel_4_ia_min1) ///
		(rel_5=gen_st_tch_rel_5+gen_st_tch_rel_5_ia_min1) ///
		(rel_6=gen_st_tch_rel_6+gen_st_tch_rel_6_ia_min1) ///
		(rel_7=gen_st_tch_rel_7+gen_st_tch_rel_7_ia_min1) ///
		(rel_8=gen_st_tch_rel_8+gen_st_tch_rel_8_ia_min1) ///
		(rel_9=gen_st_tch_rel_9+gen_st_tch_rel_9_ia_min1) ///
		(rel_10=gen_st_tch_rel_10+gen_st_tch_rel_10_ia_min1) ///
		(rel_11=gen_st_tch_rel_11+gen_st_tch_rel_11_ia_min1) ///
		(rel_12=gen_st_tch_rel_12+gen_st_tch_rel_12_ia_min1) ///
		(rel_13=gen_st_tch_rel_13+gen_st_tch_rel_13_ia_min1) ///
		(rel_14=gen_st_tch_rel_14+gen_st_tch_rel_14_ia_min1), post
estimate store ev_ia_min1_high_ela

coefplot (ev_ia_min1_low_ela,  msymbol(O) mlcolor(black) mfcolor(black) ciopts(recast(rcap) color(black)) ) ///
		 (ev_ia_min1_high_ela, msymbol(O) mlcolor(gs7*.5) mfcolor(gs7*.5) ciopts(recast(rcap) color(gs7*.5))), vert ///
coeflabel(rel_3="-6" rel_4="-5" rel_5="-4" rel_6="-3" rel_7="-2" rel_8="-1" rel_9="0" rel_10="1" rel_11="2" rel_12="3" rel_13="4"  rel_14="5") ///
xtitle("Years Relative to Teacher Evaluation") xline(6, lp(solid) lcolor(gs3)) xlabel(, labsize(small)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) lcol(black)) ///
ytitle("ELA Effect SD") ///
yscale(range(-.1 .1)) ylabel(-.1(.02).1, labsize(small)) levels(95) ///
yline(-.1 -.08 -.06 -.04 -.02 0 .02 .04 .06 .08 .1, lp(solid) lc(gs12) lwid(vthin)) ///
yline(0, lp(dash) lc(black)) scheme(s2color) ///
legend(order(2 "Tch Eval" 4 "Tch Eval + Incentives/Accountability"))

graph export "Output/figure_5_panel_a_incent_acct_het_ela.pdf", as(pdf) replace

//Feedback/Measurment
local st_event_dummies gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_8

local st_event_dummies_all gen_st_tch_rel_3_pd_all gen_st_tch_rel_4_pd_all gen_st_tch_rel_5_pd_all gen_st_tch_rel_6_pd_all gen_st_tch_rel_7_pd_all gen_st_tch_rel_9_pd_all gen_st_tch_rel_10_pd_all gen_st_tch_rel_11_pd_all gen_st_tch_rel_12_pd_all gen_st_tch_rel_13_pd_all gen_st_tch_rel_14_pd_all gen_st_tch_rel_8_pd_all

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

qui reghdfe cs_mn_all `st_event_dummies'  `st_event_dummies_all' ///
`cov' `ses_cov' `ach' ///
 if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store pd_all_ev_pch_math

estimate restore pd_all_ev_pch_math
xlincom (rel_3=gen_st_tch_rel_3) ///
		(rel_4=gen_st_tch_rel_4) ///
		(rel_5=gen_st_tch_rel_5) ///
		(rel_6=gen_st_tch_rel_6) ///
		(rel_7=gen_st_tch_rel_7) ///
		(rel_8=gen_st_tch_rel_8) ///
		(rel_9=gen_st_tch_rel_9) ///
		(rel_10=gen_st_tch_rel_10) ///
		(rel_11=gen_st_tch_rel_11) ///
		(rel_12=gen_st_tch_rel_12) ///
		(rel_13=gen_st_tch_rel_13) ///
		(rel_14=gen_st_tch_rel_14), post
estimate store ev_pd_all_low_math

estimate restore pd_all_ev_pch_math
xlincom (rel_3=gen_st_tch_rel_3+gen_st_tch_rel_3_pd_all) ///
		(rel_4=gen_st_tch_rel_4+gen_st_tch_rel_4_pd_all) ///
		(rel_5=gen_st_tch_rel_5+gen_st_tch_rel_5_pd_all) ///
		(rel_6=gen_st_tch_rel_6+gen_st_tch_rel_6_pd_all) ///
		(rel_7=gen_st_tch_rel_7+gen_st_tch_rel_7_pd_all) ///
		(rel_8=gen_st_tch_rel_8+gen_st_tch_rel_8_pd_all) ///
		(rel_9=gen_st_tch_rel_9+gen_st_tch_rel_9_pd_all) ///
		(rel_10=gen_st_tch_rel_10+gen_st_tch_rel_10_pd_all) ///
		(rel_11=gen_st_tch_rel_11+gen_st_tch_rel_11_pd_all) ///
		(rel_12=gen_st_tch_rel_12+gen_st_tch_rel_12_pd_all) ///
		(rel_13=gen_st_tch_rel_13+gen_st_tch_rel_13_pd_all) ///
		(rel_14=gen_st_tch_rel_13+gen_st_tch_rel_14_pd_all), post
estimate store ev_pd_all_high_math

coefplot (ev_pd_all_low_math,  msymbol(O) mlcolor(black) mfcolor(black) ciopts(recast(rcap) color(black)) ) ///
		 (ev_pd_all_high_math, msymbol(O) mlcolor(gs7*.5) mfcolor(gs7*.5) ciopts(recast(rcap) color(gs7*.5))), vert ///
coeflabel(rel_3="-6" rel_4="-5" rel_5="-4" rel_6="-3" rel_7="-2" rel_8="-1" rel_9="0" rel_10="1" rel_11="2" rel_12="3" rel_13="4"  rel_14="5") ///
xtitle("Years Relative to Teacher Evaluation") xline(6, lp(solid) lcolor(gs3)) xlabel(, labsize(small)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) lcol(black)) ///
ytitle("Math Effect SD") ///
yscale(range(-.1 .1)) ylabel(-.1(.02).1, labsize(small)) levels(95) ///
yline(-.1 -.08 -.06 -.04 -.02 0 .02 .04 .06 .08 .1, lp(solid) lc(gs12) lwid(vthin)) ///
yline(0, lp(dash) lc(black)) scheme(s2color) ///
legend(order(2 "Tch Eval" 4 "Tch Eval + Feedback/PD"))
			 
graph export "Output/figure_5_panel_a_feedback_pd_het_math.pdf", as(pdf) replace

local st_event_dummies gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_8

local st_event_dummies_all gen_st_tch_rel_3_pd_all gen_st_tch_rel_4_pd_all gen_st_tch_rel_5_pd_all gen_st_tch_rel_6_pd_all gen_st_tch_rel_7_pd_all gen_st_tch_rel_9_pd_all gen_st_tch_rel_10_pd_all gen_st_tch_rel_11_pd_all gen_st_tch_rel_12_pd_all gen_st_tch_rel_13_pd_all gen_st_tch_rel_14_pd_all gen_st_tch_rel_8_pd_all

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

qui reghdfe cs_mn_all `st_event_dummies' `st_event_dummies_all' ///
`cov' `ses_cov' `ach' ///
 if subject=="rla" & st_trim_sample==1 & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store pd_all_ev_pch_ela

estimate restore pd_all_ev_pch_ela
xlincom (rel_3=gen_st_tch_rel_3) ///
		(rel_4=gen_st_tch_rel_4) ///
		(rel_5=gen_st_tch_rel_5) ///
		(rel_6=gen_st_tch_rel_6) ///
		(rel_7=gen_st_tch_rel_7) ///
		(rel_8=gen_st_tch_rel_8) ///
		(rel_9=gen_st_tch_rel_9) ///
		(rel_10=gen_st_tch_rel_10) ///
		(rel_11=gen_st_tch_rel_11) ///
		(rel_12=gen_st_tch_rel_12) ///
		(rel_13=gen_st_tch_rel_13) ///
		(rel_14=gen_st_tch_rel_14), post
estimate store ev_pd_all_low_ela

estimate restore pd_all_ev_pch_ela
xlincom (rel_3=gen_st_tch_rel_3+gen_st_tch_rel_3_pd_all) ///
		(rel_4=gen_st_tch_rel_4+gen_st_tch_rel_4_pd_all) ///
		(rel_5=gen_st_tch_rel_5+gen_st_tch_rel_5_pd_all) ///
		(rel_6=gen_st_tch_rel_6+gen_st_tch_rel_6_pd_all) ///
		(rel_7=gen_st_tch_rel_7+gen_st_tch_rel_7_pd_all) ///
		(rel_8=gen_st_tch_rel_8+gen_st_tch_rel_8_pd_all) ///
		(rel_9=gen_st_tch_rel_9+gen_st_tch_rel_9_pd_all) ///
		(rel_10=gen_st_tch_rel_10+gen_st_tch_rel_10_pd_all) ///
		(rel_11=gen_st_tch_rel_11+gen_st_tch_rel_11_pd_all) ///
		(rel_12=gen_st_tch_rel_12+gen_st_tch_rel_12_pd_all) ///
		(rel_13=gen_st_tch_rel_13+gen_st_tch_rel_13_pd_all) ///
		(rel_14=gen_st_tch_rel_13+gen_st_tch_rel_14_pd_all), post
estimate store ev_pd_all_high_ela

coefplot (ev_pd_all_low_ela,  msymbol(O) mlcolor(black) mfcolor(black) ciopts(recast(rcap) color(black)) ) ///
		 (ev_pd_all_high_ela, msymbol(O) mlcolor(gs7*.5) mfcolor(gs7*.5) ciopts(recast(rcap) color(gs7*.5))), vert ///
coeflabel(rel_3="-6" rel_4="-5" rel_5="-4" rel_6="-3" rel_7="-2" rel_8="-1" rel_9="0" rel_10="1" rel_11="2" rel_12="3" rel_13="4"  rel_14="5") ///
xtitle("Years Relative to Teacher Evaluation") xline(6, lp(solid) lcolor(gs3)) xlabel(, labsize(small)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) lcol(black)) ///
ytitle("ELA Effect SD") ///
yscale(range(-.1 .1)) ylabel(-.1(.02).1, labsize(small)) levels(95) ///
yline(-.1 -.08 -.06 -.04 -.02 0 .02 .04 .06 .08 .1, lp(solid) lc(gs12) lwid(vthin)) ///
yline(0, lp(dash) lc(black)) scheme(s2color) ///
legend(order(2 "Tch Eval" 4 "Tch Eval + Feedback/PD"))

graph export "Output/figure_5_panel_a_feedback_pd_het_ela.pdf", as(pdf) replace
********************************************************************************
********************************************************************************
**# FIGURE VI-Event Study and Estimates Robust to Heterogenous Effects Across Cohorts
********************************************************************************
********************************************************************************
//Achievement
use "Data/achievement_data.dta", clear

local years 2012 2013 2014 2015 2016 2017
foreach i of local years{
preserve

gen keepvar=0
replace keepvar=1 if gen_st_tch_eval_imp_yr==`i'
replace keepvar=1 if st_ever_iw==0
keep if keepvar==1
gen stack=`i'
save "Data/stack_`i'.dta", replace
restore
}
********************************************************************************
//Appending
use "Data/stack_2012.dta", clear
append using "Data/stack_2013.dta" "Data/stack_2014.dta" "Data/stack_2015.dta" "Data/stack_2016.dta" "Data/stack_2017.dta"

gen state_stack=fips*stack
********************************************************************************
//Stacked Event Studies
local st_event_dummies gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_8

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

//Math
qui reghdfe cs_mn_all `st_event_dummies' `cov' `ses_cov' `ach' if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(i.leaid_num##i.stack i.year##i.stack grade) cluster(fips state_stack)
estimate store stack_ev_m
//ELA
qui reghdfe cs_mn_all `st_event_dummies' `cov' `ses_cov' `ach' if subject=="rla" & st_trim_sample==1 & st_ela_smp==1, absorb(i.leaid_num##i.stack i.year##i.stack grade) cluster(fips state_stack)
estimate store stack_ev_e
********************************************************************************
//Sun Abraham Estimator
use "Data/achievement_data.dta", clear

drop if fips==.

gen cohort=gen_st_tch_eval_imp_yr
recode cohort (0=.)

gen rel_time=gen_st_tch_rel
replace rel_time=rel_time-1

gen ever_treat=st_ever_iw
recode ever_treat (1=0) (0=1)

local st_event_dummies gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_8

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

eventstudyinteract cs_mn_all `st_event_dummies' if subject=="mth" & st_trim_sample==1 & st_math_smp==1, ///
	 cohort(cohort) control_cohort(ever_treat) covariates(`cov' `ses_cov' `ach') ///
	 vce(cluster fips) absorb(leaid_num year grade)
	 
matrix C = e(b_iw)
mata st_matrix("A",sqrt(st_matrix("e(V_iw)")))
matrix  A = vecdiag(A)
matrix sa_m = C \ A
matrix list sa_m

eventstudyinteract cs_mn_all `st_event_dummies' if subject=="rla" & st_trim_sample==1 & st_ela_smp==1, ///
	 cohort(cohort) control_cohort(ever_treat) covariates(`cov' `ses_cov' `ach') ///
	 vce(cluster fips) absorb(leaid_num year grade)
	 
matrix C = e(b_iw)
mata st_matrix("A",sqrt(st_matrix("e(V_iw)")))
matrix  A = vecdiag(A)
matrix sa_e = C \ A
matrix list sa_e

********************************************************************************
//Conventional Event Study
use "Data/achievement_data.dta", clear
local st_event_dummies gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_8

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

qui reghdfe cs_mn_all `st_event_dummies' `cov' `ses_cov' `ach' i.grade i.year  if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store ev_pach_st_math

qui reghdfe cs_mn_all `st_event_dummies' `cov' `ses_cov' `ach' i.grade i.year  if subject=="rla" & st_trim_sample==1 & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store ev_pach_st_ela

coefplot (ev_pach_st_math, msymbol(O) mlcolor(black) mfcolor(black) ciopts(recast(rcap) lcolor(black))) ///
		 (matrix(sa_m[1]), se(sa_m[2]) msymbol(D)  mlcolor(gs9*.8) mfcolor(gs9*.8) ciopts(recast(rcap) lcolor(gs9*.8))) ///
		 (stack_ev_m, msymbol(T) mlcolor(gs3*.8) mfcolor(gs3*.8) ciopts(recast(rcap) lcolor(gs3*.8))), ///
vert rename(gen_st_tch_rel_3="-6" gen_st_tch_rel_4="-5" gen_st_tch_rel_5="-4" gen_st_tch_rel_6="-3" ///
gen_st_tch_rel_7="-2" gen_st_tch_rel_8="-1" gen_st_tch_rel_9="0" gen_st_tch_rel_10="1" ///
gen_st_tch_rel_11="2" gen_st_tch_rel_12="3" gen_st_tch_rel_13="4" gen_st_tch_rel_14="5") ///
order("-6" "-5" "-4" "-3" "-2" "-1" "0" "1" "2" "3" "4" "5") ///
xtitle("State General Teacher Eval Implemented (Year)") xline(6, lp(solid) lcolor(black)) xlabel(, labsize(small)) ///
graphregion(color(white)) bgcolor(white) omitted  ///
ytitle("Math Score SD") yscale(range(-.1 .1)) ylabel(-.1(.02).1, labsize(small)) levels(95) ///
yline(0, lp(solid) lc(black)) ///
yline(-0.10 -0.08 -0.06 -0.04 -0.02 0.02 0.04 0.06 0.08 0.10, lp(solid) lc(gs12) lwid(vthin)) ///
keep(gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 ///
gen_st_tch_rel_8 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14) ///
legend(off)

graph export "Output/figure_6_panel_a_cohort_het_robust_math.pdf", as(pdf) replace

coefplot (ev_pach_st_ela, msymbol(O) mlcolor(black) mfcolor(black) ciopts(recast(rcap) lcolor(black))) ///
		 (matrix(sa_e[1]), se(sa_e[2]) msymbol(D)  mlcolor(gs7*.8) mfcolor(gs7*.8) ciopts(recast(rcap) lcolor(gs9*.8))) ///
		 (stack_ev_e, msymbol(T) mlcolor(gs4*.8) mfcolor(gs4*.8) ciopts(recast(rcap) lcolor(gs3*.8))) , ///
vert rename(gen_st_tch_rel_3="-6" gen_st_tch_rel_4="-5" gen_st_tch_rel_5="-4" gen_st_tch_rel_6="-3" ///
gen_st_tch_rel_7="-2" gen_st_tch_rel_8="-1" gen_st_tch_rel_9="0" gen_st_tch_rel_10="1" ///
gen_st_tch_rel_11="2" gen_st_tch_rel_12="3" gen_st_tch_rel_13="4" gen_st_tch_rel_14="5") ///
order("-6" "-5" "-4" "-3" "-2" "-1" "0" "1" "2" "3" "4" "5") ///
xtitle("State General Teacher Eval Implemented (Year)") xline(6, lp(solid) lcolor(black)) xlabel(, labsize(small)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) lcolor(black)) ///
ytitle("ELA Score SD") yscale(range(-.1 .1)) ylabel(-.1(.02).1, labsize(small)) levels(95) ///
yline(0, lp(solid) lc(black)) ///
yline(-0.10 -0.08 -0.06 -0.04 -0.02 0.02 0.04 0.06 0.08 0.10, lp(solid) lc(gs12) lwid(vthin)) ///
keep(gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 ///
gen_st_tch_rel_8 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14) ///
legend(off)

graph export "Output/figure_6_panel_a_cohort_het_robust_ela.pdf", as(pdf) replace

********************************************************************************
*Attainement
//Stacked Regression
local years 2012 2013 2014 2015 2016 2017
foreach i of local years{
preserve
use "Data/attainment_data.dta", clear
gen keepvar=0
replace keepvar=1 if gen_st_tch_eval_imp_yr==`i'
replace keepvar=1 if gen_st_tch_eval_ever==0
keep if keepvar==1
gen stack=`i'
save "Data/ipums_attain_`i'.dta", replace
restore
}
********************************************************************************
//Appending
use "Data/ipums_attain_2012.dta", clear
append using "Data/ipums_attain_2013.dta" "Data/ipums_attain_2014.dta" "Data/ipums_attain_2015.dta" "Data/ipums_attain_2016.dta" "Data/ipums_attain_2017.dta"

gen state_stack=fips*stack

********************************************************************************
//Stacked Event Study
local event_dummies gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 ///
				    gen_st_tch_rel_8 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 ///
					gen_st_tch_rel_14 gen_st_tch_rel_15 gen_st_tch_rel_16 gen_st_tch_rel_17 gen_st_tch_rel_18 gen_st_tch_rel_9
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l urban_l gdp_st_l hs_no_ged_a20_base_l ela_sd_naep_l math_sd_naep_l

reghdfe hs_no_ged_a20 `event_dummies' `covars' if trim_sample==0, absorb(i.fips##i.stack i.year##i.stack) cluster(fips state_stack)
estimate store stack_ev_hs_grad
********************************************************************************
//Sun Abraham
use "Data/attainment_data.dta", clear
drop if fips==.

gen cohort=gen_st_tch_eval_imp_yr
recode cohort (0=.)

gen rel_time=gen_st_tch_rel
replace rel_time=rel_time-1

gen ever_treat=gen_st_tch_eval_ever
recode ever_treat (1=0) (0=1)


local event_dummies gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 ///
				    gen_st_tch_rel_8 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 ///
					gen_st_tch_rel_14 gen_st_tch_rel_15 gen_st_tch_rel_16 gen_st_tch_rel_17 gen_st_tch_rel_18 gen_st_tch_rel_9
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l hs_no_ged_a20_base_l ela_sd_naep_l math_sd_naep_l

eventstudyinteract hs_no_ged_a20 `event_dummies' if hs_grad_a20_smp==1 & trim_sample==0, ///
	 cohort(cohort) control_cohort(ever_treat) covariates(`covars') ///
	 vce(cluster fips) absorb(fips year)

matrix rtable=r(table)
matrix rtable=rtable'
matrix B = rtable[1..14,1]
matrix SE = rtable[1..14,2]
matrix sa_hs_grad = B , SE
matrix sa_hs_grad=sa_hs_grad'
matrix list sa_hs_grad
********************************************************************************
//Conventional Event Study
local event_dummies gen_st_tch_rel_5-gen_st_tch_rel_8 gen_st_tch_rel_10-gen_st_tch_rel_18 gen_st_tch_rel_9
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l hs_no_ged_a20_base_l ela_sd_naep_l math_sd_naep_l
reghdfe hs_no_ged_a20 `event_dummies' `covars' ///
if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store hs_no_ged_a20_event_cov

coefplot (hs_no_ged_a20_event_cov , msymbol(O) mlcolor(black) mfcolor(black) ciopts(recast(rcap) lcolor(black))) ///
		 (matrix(sa_hs_grad[1]), se(sa_hs_grad[2]) msymbol(D)  mlcolor(gs7*.8) mfcolor(gs7*.8) ciopts(recast(rcap) lcolor(gs7*.8))) ///
		 (stack_ev_hs_grad, msymbol(T) mlcolor(gs4*.8) mfcolor(gs4*.8) ciopts(recast(rcap) lcolor(gs4*.8))), ///
vert rename(gen_st_tch_rel_5="-5" ///
			gen_st_tch_rel_6="-4" ///
			gen_st_tch_rel_7="-3" ///
			gen_st_tch_rel_8="-2" ///
			gen_st_tch_rel_9="-1" ///
			gen_st_tch_rel_10="0" ///
			gen_st_tch_rel_11="1" ///
			gen_st_tch_rel_12="2" ///
			gen_st_tch_rel_13="3" ///
			gen_st_tch_rel_14="4" ///
			gen_st_tch_rel_15="5" ///
			gen_st_tch_rel_16="6" ///
			gen_st_tch_rel_17="7" ///
			gen_st_tch_rel_18="8") ///
order("-5" "-4" "-3" "-2" "-1" "0" "1" "2" "3" "4" "5" "6" "7" "8") ///
xtitle("State Teacher Eval Implemented (Year)") xline(5, lp(solid) lcolor(black)) ///
ytitle("% HS Graduates") yscale(range(-5 5)) levels(95) /// ///
ylabel(-10 "-10%"  -8 "-8%"  -6 "-6%"  -4 "-4%"  -2 "-2%"  ///
0 "0%"   2 "2%"  4 "4%"  6 "6%"  8 "8%"  10 "10%", ///
angle(45) labsize(small) labc(black)) ///
graphregion(color(white)) bgcolor(white) omitted ///
yline(0, lp(solid) lc(black)) ///
yline(-10  -8 -6 -4 -2 2 4 6 8 10, lp(solid) lc(gs12) lwid(vthin)) ///
keep(gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_8 ///
		   gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 ///
		   gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_15 gen_st_tch_rel_16 gen_st_tch_rel_17 gen_st_tch_rel_18) ///
legend(off) 

graph export "Output/figure_6_panel_b_cohort_het_robust_hs_grad.pdf", as(pdf) replace

********************************************************************************
//College Enrollment
********************************************************************************
//Stacked Regression
local years 2012 2013 2014 2015 2016 2017
foreach i of local years{
preserve
use "Data/attainment_data.dta", clear
gen keepvar=0
replace keepvar=1 if gen_st_tch_eval_imp_yr==`i'
replace keepvar=1 if gen_st_tch_eval_ever==0
keep if keepvar==1
gen stack=`i'
save "Data/pums_attain_`i'.dta", replace
restore
}
********************************************************************************
//Appending
use "Data/ipums_attain_2012.dta", clear
append using "Data/ipums_attain_2013.dta" "Data/ipums_attain_2014.dta" "Data/ipums_attain_2015.dta" "Data/ipums_attain_2016.dta" "Data/ipums_attain_2017.dta"

gen state_stack=fips*stack

********************************************************************************
//Stacked Event Study
local event_dummies gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 ///
				    gen_st_tch_rel_8 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 ///
					gen_st_tch_rel_14 gen_st_tch_rel_15 gen_st_tch_rel_16 gen_st_tch_rel_17 gen_st_tch_rel_18 gen_st_tch_rel_9
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l enroll_pct_a22_base_l ela_sd_naep_l math_sd_naep_l

reghdfe enroll_pct_a22 `event_dummies' `covars' if trim_sample==0, absorb(i.fips##i.stack i.year##i.stack) cluster(fips state_stack)
estimate store stack_ev_col_enrl
********************************************************************************
//Sun Abraham
use "Data/attainment_data.dta", clear
drop if fips==.

gen cohort=gen_st_tch_eval_imp_yr
recode cohort (0=.)

gen rel_time=gen_st_tch_rel
replace rel_time=rel_time-1

gen ever_treat=gen_st_tch_eval_ever
recode ever_treat (1=0) (0=1)


local event_dummies gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 ///
				    gen_st_tch_rel_8 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 ///
					gen_st_tch_rel_14 gen_st_tch_rel_15 gen_st_tch_rel_16 gen_st_tch_rel_17 gen_st_tch_rel_18 gen_st_tch_rel_9
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l enroll_pct_a22_base_l ela_sd_naep_l math_sd_naep_l

eventstudyinteract enroll_pct_a22 `event_dummies' if trim_sample==0, ///
	 cohort(cohort) control_cohort(ever_treat) covariates(`covars') ///
	 vce(cluster fips) absorb(fips year)

matrix rtable=r(table)
matrix rtable=rtable'
matrix B = rtable[1..14,1]
matrix SE = rtable[1..14,2]
matrix sa_col_enrl = B , SE
matrix sa_col_enrl=sa_col_enrl'
matrix list sa_col_enrl
********************************************************************************
//Conventional Event Study
local event_dummies gen_st_tch_rel_5-gen_st_tch_rel_8 gen_st_tch_rel_10-gen_st_tch_rel_17 gen_st_tch_rel_18 gen_st_tch_rel_9
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l enroll_pct_a22_base_l ela_sd_naep_l math_sd_naep_l
reghdfe enroll_pct_a22 `event_dummies' `covars' ///
if trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store enroll_pct_a22_event_cov

coefplot (enroll_pct_a22_event_cov , msymbol(O) mlcolor(black) mfcolor(black) ciopts(recast(rcap) lcolor(black))) ///
		 (matrix(sa_col_enrl[1]), se(sa_col_enrl[2]) msymbol(D)  mlcolor(gs7*.8) mfcolor(gs7*.8) ciopts(recast(rcap) lcolor(gs7*.8))) ///
		 (stack_ev_col_enrl, msymbol(T) mlcolor(gs4*.8) mfcolor(gs4*.8) ciopts(recast(rcap) lcolor(gs4*.8))) , ///
vert rename(gen_st_tch_rel_5="-5" ///
			gen_st_tch_rel_6="-4" ///
			gen_st_tch_rel_7="-3" ///
			gen_st_tch_rel_8="-2" ///
			gen_st_tch_rel_9="-1" ///
			gen_st_tch_rel_10="0" ///
			gen_st_tch_rel_11="1" ///
			gen_st_tch_rel_12="2" ///
			gen_st_tch_rel_13="3" ///
			gen_st_tch_rel_14="4" ///
			gen_st_tch_rel_15="5" ///
			gen_st_tch_rel_16="6" ///
			gen_st_tch_rel_17="7" ///
			gen_st_tch_rel_18="8") ///
order("-5" "-4" "-3" "-2" "-1" "0" "1" "2" "3" "4" "5" "6" "7" "8") ///
xtitle("State Teacher Eval Implemented (Year)") xline(5, lp(solid) lcolor(black)) ///
ytitle("% College Enrollment") yscale(range(-5 5)) levels(95) /// ///
ylabel(-10 "-10%"  -8 "-8%"  -6 "-6%"  -4 "-4%"  -2 "-2%"  ///
0 "0%"   2 "2%"  4 "4%"  6 "6%"  8 "8%"  10 "10%", ///
angle(45) labsize(small) labc(black)) ///
graphregion(color(white)) bgcolor(white) omitted ///
yline(0, lp(solid) lc(black)) ///
yline(-10  -8 -6 -4 -2 2 4 6 8 10, lp(solid) lc(gs12) lwid(vthin)) ///
keep(gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_8 ///
		   gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 ///
		   gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_15 gen_st_tch_rel_16 gen_st_tch_rel_17 gen_st_tch_rel_18) ///
legend(off)

graph export "Output/figure_6_panel_b_cohort_het_robust_col_enrl.pdf", as(pdf) replace

********************************************************************************
********************************************************************************
**# APPENDIX TABLE A.1- Observations and States Across Relative Time
********************************************************************************
********************************************************************************
use "Data/achievement_data.dta", clear
putexcel set "Output/appendix_table_a1_obs_states_across_times.xlsx", modify
	
local rows=3
levelsof gen_st_tch_rel
local rel_time=r(levels)
foreach i of local rel_time{
qui unique fips if gen_st_tch_rel==`i' & st_ever_iw==1
matrix unique=r(unique)
putexcel B`rows'=matrix(unique)

matrix scount=r(N)
putexcel C`rows'=matrix(scount)
local rows=`rows'+1
}
putexcel A1="Panel A. Achievement"
putexcel A2="Relative Time"
putexcel B2="Treated States"
putexcel C2="N"
putexcel D2="Trimmed"
putexcel A3="Pre -8"
putexcel A4="Pre -7"
putexcel A5="Pre -6"
putexcel A6="Pre -5"
putexcel A7="Pre -4"
putexcel A8="Pre -3"
putexcel A9="Pre -2"
putexcel A10="Pre -1"
putexcel A11="Post 0"
putexcel A12="Post 1"
putexcel A13="Post 2"
putexcel A14="Post 3"
putexcel A15="Post 4"
putexcel A16="Post 5"
putexcel A17="Post 6"
putexcel A18="Post 7"
putexcel A19="Post 8"
putexcel A20="Post 9"
putexcel D3="X"
putexcel D4="X"
putexcel D20="X"

use "Data/attainment_data.dta", clear
drop if fips==11
local rows=25
levelsof gen_st_tch_rel
local rel_time=r(levels)
foreach i of local rel_time{
qui unique fips if gen_st_tch_rel==`i' & gen_st_tch_eval_ever==1
matrix unique=r(unique)
putexcel B`rows'=matrix(unique)

matrix scount=r(N)
putexcel C`rows'=matrix(scount)
local rows=`rows'+1
}

putexcel A23="Panel B. Attainment"
putexcel B24="Relative Time"
putexcel C24="N"
putexcel D24="Trimmed"
putexcel A25="Pre -8"
putexcel A26="Pre -7"
putexcel A27="Pre -6"
putexcel A28="Pre -5"
putexcel A29="Pre -4"
putexcel A30="Pre -3"
putexcel A31="Pre -2"
putexcel A32="Pre -1"
putexcel A33="Post 0"
putexcel A34="Post 1"
putexcel A35="Post 2"
putexcel A36="Post 3"
putexcel A37="Post 4"
putexcel A38="Post 5"
putexcel A39="Post 6"
putexcel A40="Post 7"
putexcel A41="Post 8"
putexcel A42="Post 9"
putexcel A43="Post 10"
putexcel A44="Post 11"
putexcel D25="X"
putexcel D26="X"
putexcel D27="X"
putexcel D42="X"
putexcel D43="X"
putexcel D44="X"

********************************************************************************
********************************************************************************
**# APPENDIX TABLE A.2-Event Study Achievement Effects
********************************************************************************
********************************************************************************
use "Data/achievement_data.dta", clear

local st_event_dummies gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_8

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l


qui reghdfe cs_mn_all `st_event_dummies'  if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
	estimate store ev_st_math
qui reghdfe cs_mn_all `st_event_dummies' `cov' `ses_cov' `ach'  if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
	estimate store ev_pach_st_math

qui reghdfe cs_mn_all `st_event_dummies' `cov' `ses_cov' `ach'  if subject=="rla" & st_trim_sample==1 & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
	estimate store ev_pach_st_ela
qui reghdfe cs_mn_all `st_event_dummies'  if subject=="rla" & st_trim_sample==1 & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
	estimate store ev_st_ela


esttab ev_st_math ev_pach_st_math ev_st_ela ev_pach_st_ela ///
	using "Output/appendix_table_a2_achievement_event_study.csv", ///
	label ///
	nodepvars ///
	b(4) ///
	t(4) ///
	sfmt (4 0 0 0) ///
	replace  ///
	se(4) ///
	nomtitle ///
	nonote ///
	nogap ///
	stat(N, label("n") fmt(a3)) ///
	keep(gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14)
	
********************************************************************************
********************************************************************************
**# APPENDIX TABLE A.3-Event Study Attainment Effects
********************************************************************************
********************************************************************************
use "Data/attainment_data.dta", clear

local event_dummies gen_st_tch_rel_5-gen_st_tch_rel_8 gen_st_tch_rel_10-gen_st_tch_rel_18 gen_st_tch_rel_9 ref
//Event without Covariates
qui reghdfe hs_no_ged_a20 `event_dummies' if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store hs_no_ged_a20_event
qui reghdfe enroll_pct_a22 `event_dummies' if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year) cluster(fips)
	estimate store enroll_pct_a22_event

	//Event with Covariates
local event_dummies gen_st_tch_rel_5-gen_st_tch_rel_8 gen_st_tch_rel_10-gen_st_tch_rel_18 gen_st_tch_rel_9 ref
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l hs_no_ged_a20_base_l ela_sd_naep_l math_sd_naep_l
qui reghdfe hs_no_ged_a20 `event_dummies' `covars' ///
if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store hs_no_ged_a20_event_cov	
	
local event_dummies gen_st_tch_rel_5-gen_st_tch_rel_8 gen_st_tch_rel_10-gen_st_tch_rel_18 gen_st_tch_rel_9 ref
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l enroll_pct_a22_base_l ela_sd_naep_l math_sd_naep_l
qui reghdfe enroll_pct_a22 `event_dummies' `covars' ///
if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year) cluster(fips)
	estimate store enroll_pct_a22_event_cov

	esttab hs_no_ged_a20_event hs_no_ged_a20_event_cov enroll_pct_a22_event enroll_pct_a22_event_cov ///
	using "Output/appendix_table_a3_attainment_event_study.csv", ///
	label ///
	nodepvars ///
	b(4) ///
	t(4) ///
	sfmt (4 0 0 0) ///
	replace  ///
	se(4) ///
	nomtitle ///
	nonote ///
	nogap ///
	stat(N, label("n") fmt(a3)) ///
	coeflabel(gen_st_tch_rel_5 "Pre 5" ///
			  gen_st_tch_rel_6 "Pre 4" ///
			  gen_st_tch_rel_7 "Pre 3" ///
			  gen_st_tch_rel_8 "Pre 2" ///
			  gen_st_tch_rel_10 "Post 0" ///
			  gen_st_tch_rel_11 "Post 1" ///
			  gen_st_tch_rel_12 "Post 2" ///
			  gen_st_tch_rel_13 "Post 3" ///
			  gen_st_tch_rel_14 "Post 4" ///
			  gen_st_tch_rel_15 "Post 5" ///
			  gen_st_tch_rel_16 "Post 6" ///
			  gen_st_tch_rel_17 "Post 7" ///
			  gen_st_tch_rel_18 "Post 8") ///
	keep(gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_8 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 ///
		   gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_15 gen_st_tch_rel_16 gen_st_tch_rel_17 gen_st_tch_rel_18)	
********************************************************************************
********************************************************************************
**# APPENDIX TABLE A.4-Effect of Teacher Evaluation with Time-Varying Covariates
********************************************************************************
********************************************************************************

******Panel A******
//District Time Varying Controls- Achievement
	//Baseline district linear trends in achievement
	//Full set of district time-varying covariates
	
use "Data/achievement_data.dta", clear

local t_covar perblk perhsp perind perasn urban ppe_inst totenrl stud_tch_ratio gdp povertyall unempall
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

//Math
qui reghdfe cs_mn_all gen_st_tch_eval_imp `t_covar' `ach' if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store ev_ach_tvar_math
//ELA
qui reghdfe cs_mn_all gen_st_tch_eval_imp `t_covar' `ach' if subject=="rla" & st_trim_sample==1  & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store ev_ach_tvar_ela

******Panel B******
//State Time Varying Controls- Achievement
	//Baseline district linear trends in achievement
	//Full set of state time-varying covariates: Including state unemployment and state PPE

use "Data/achievement_data.dta", clear

//Collapsing to State Level
preserve
use "Data/achievement_data.dta", clear
collapse (mean) perblk perhsp perind perasn urban ppe_inst stud_tch_ratio totenrl, by(fips year)

gen stfips=fips

//ACS state characteristics
	*Source: IPUMS https://www.ipums.org/
merge 1:1 stfips year using "Data/acs_state_covars.dta", nogen keep(master match)

//Imputing CCD variables are missing in some state years and in 2022
qui levelsof fips, local(states)
foreach s of local states{
local vars perblk perhsp perind perasn urban ppe_inst stud_tch_ratio totenrl ppov unemp_rate gdp
foreach i of local vars{
qui reg `i' year if fips==`s'
qui predict xb if fips==`s'
qui replace `i'=xb if fips==`s' & `i'==.
drop xb
}
}
tempfile seda_st_cov
save "`seda_st_cov'"
restore

drop urban stud_tch_ratio
merge m:1 fips year using "`seda_st_cov'", nogen keep(master match)


local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l
local t_covar perblk perhsp perind perasn urban ppe_inst stud_tch_ratio totenrl ppov unemp_rate gdp

//Math
qui reghdfe cs_mn_all gen_st_tch_eval_imp `ach' `t_covar' if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store new_math_cov
//ELA
qui reghdfe cs_mn_all gen_st_tch_eval_imp `ach' `t_covar' if subject=="rla" & st_trim_sample==1  & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store new_ela_cov

******Panel C******
//State Time Varying Controls- Attainment
	//Baseline state linear trends in attainment
	//Full set of state time-varying covariates: Including state unemployment and state PPE
use "Data/attainment_data.dta", clear

preserve
use "Data/achievement_data.dta", clear
collapse (mean) perblk perhsp perind perasn urban ppe_inst stud_tch_ratio totenrl, by(fips year)
tempfile seda_st_cov
save "`seda_st_cov'"
restore

drop urban stud_tch_ratio

merge 1:1 fips year using "`seda_st_cov'", nogen keep(master match)
gen stfips=fips

//ACS state characteristics
	*Source: IPUMS https://www.ipums.org/
merge 1:1 stfips year using "Data/acs_state_covars.dta", nogen keep(master match)


//Imputing CCD variables are missing in some state years and in 2022
qui levelsof fips, local(states)
foreach s of local states{
local vars perblk perhsp perind perasn urban ppe_inst stud_tch_ratio totenrl ppov unemp_rate gdp
foreach i of local vars{
qui reg `i' year if fips==`s'
qui predict xb if fips==`s'
qui replace `i'=xb if fips==`s' & `i'==.
drop xb
}
}

//HS Graduation
local ach hs_no_ged_a20_base_l
local t_covar perblk perhsp perind perasn urban ppe_inst stud_tch_ratio totenrl ppov unemp_rate gdp
reghdfe hs_no_ged_a20 gen_st_tch_eval_imp `t_covar' `ach' if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store new_hs_grad_cov
	
//Some College
local ach enroll_pct_a22_base_l
local t_covar perblk perhsp perind perasn urban ppe_inst stud_tch_ratio totenrl ppov unemp_rate gdp
reghdfe enroll_pct_a22 gen_st_tch_eval_imp `t_covar' `ach' if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year) cluster(fips)
	estimate store new_some_col_cov
	
	
esttab ev_ach_tvar_math ev_ach_tvar_ela new_math_cov new_ela_cov new_hs_grad_cov new_some_col_cov ///
	using "Output/appendix_table_a4_time_varying_covariates.csv", ///
	label ///
	nodepvars ///
	b(4) ///
	t(4) ///
	sfmt (4 0 0 0) ///
	replace  ///
	se(4) ///
	nomtitle ///
	nonote ///
	nogap ///
	stat(N, label("n") fmt(a3)) ///
	keep(gen_st_tch_eval_imp)
	
********************************************************************************
********************************************************************************
**# APPENDIX TABLE A.5-Effect of Teacher Evaluation on College Graduation
********************************************************************************
********************************************************************************	
use "Data/attainment_data.dta", clear

local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l col_persist_pct_a22_base_l ela_sd_naep_l math_sd_naep_l

reghdfe col_persist_pct_a22 gen_st_tch_eval_imp if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store col_persist_pct_a22_did
reghdfe col_persist_pct_a22 gen_st_tch_eval_imp `covars' if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store col_per_pct_a22_did_covar
	
esttab col_persist_pct_a22_did col_per_pct_a22_did_covar ///
	using "Output/appendix_table_a5_effect_on_college_graduation.csv", ///
	label ///
	nodepvars ///
	b(4) ///
	t(4) ///
	sfmt (4 0 0 0) ///
	replace  ///
	se(4) ///
	nomtitle ///
	nonote ///
	nogap ///
	stat(N, label("n") fmt(a3)) ///
	coeflabel(gen_st_tch_eval_imp "Tch Eval") ///
	keep(gen_st_tch_eval_imp)	
	
********************************************************************************
********************************************************************************
**# APPENDIX TABLE A.6-Effect of Rigorously Designed Teacher Evaluation
********************************************************************************
********************************************************************************
//Achievement
use "Data/achievement_data.dta", clear

//Math
qui reghdfe cs_mn_all gen_st_tch_eval_imp eval_X_high_qual_7  if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store high_7_st_math
//ELA
qui reghdfe cs_mn_all gen_st_tch_eval_imp eval_X_high_qual_7  if subject=="rla" & st_trim_sample==1 & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store high_7_st_ela

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

//Math
qui reghdfe cs_mn_all gen_st_tch_eval_imp eval_X_high_qual_7 `cov' `ses_cov' `ach'  if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store high_7_pach_st_math
lincom gen_st_tch_eval_imp+eval_X_high_qual_7

//ELA
qui reghdfe cs_mn_all gen_st_tch_eval_imp eval_X_high_qual_7 `cov' `ses_cov' `ach'  if subject=="rla" & st_trim_sample==1  & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store high_7_pach_st_ela
lincom gen_st_tch_eval_imp+eval_X_high_qual_7

esttab high_7_st_math high_7_pach_st_math high_7_st_ela high_7_pach_st_ela ///
	using "Output/appendix_table_a6_panel_a_moderation_analysis_rig_systems.csv", ///
	label ///
	nodepvars ///
	b(4) ///
	t(4) ///
	sfmt (4 0 0 0) ///
	replace  ///
	se(4) ///
	nomtitle ///
	nonote ///
	nogap ///
	stat(N, label("n") fmt(a3)) ///
	coeflabel(gen_st_tch_eval_imp "Tch Eval" eval_X_high_qual_7 "Eval X High Quality") ///
	keep(gen_st_tch_eval_imp eval_X_high_qual_7)	
	
//Attainment
use "Data/attainment_data.dta", clear	
	
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l hs_no_ged_a20_base_l ela_sd_naep_l math_sd_naep_l

reghdfe hs_no_ged_a20 i.gen_st_tch_eval_imp##i.high_qual_7 if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store hs_no_ged_a20_het2_ncov
reghdfe hs_no_ged_a20 i.gen_st_tch_eval_imp##i.high_qual_7 `covars' if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store hs_no_ged_a20_het2_cov
lincom 1.gen_st_tch_eval_imp+1.gen_st_tch_eval_imp#1.high_qual_7

local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l enroll_pct_a22_base_l ela_sd_naep_l math_sd_naep_l

reghdfe enroll_pct_a22 i.gen_st_tch_eval_imp##i.high_qual_7 if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store enroll_pct_a22_het2_ncov
reghdfe enroll_pct_a22 i.gen_st_tch_eval_imp##i.high_qual_7 `covars' if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store enroll_pct_a22_het2_cov	
lincom 1.gen_st_tch_eval_imp+1.gen_st_tch_eval_imp#1.high_qual_7

esttab hs_no_ged_a20_het2_ncov hs_no_ged_a20_het2_cov enroll_pct_a22_het2_ncov enroll_pct_a22_het2_cov ///
	using "Output/appendix_table_a6_panel_b_moderation_analysis_rig_systems.csv", ///
	label ///
	nodepvars ///
	b(4) ///
	t(4) ///
	sfmt (4 0 0 0) ///
	replace  ///
	se(4) ///
	nomtitle ///
	nonote ///
	nogap ///
	stat(N, label("n") fmt(a3)) ///
	coeflabel(gen_st_tch_eval_imp "Tch Eval" 1.gen_st_tch_eval_imp#1.high_qual_7 "Eval X High Quality") ///
	keep(1.gen_st_tch_eval_imp 1.gen_st_tch_eval_imp#1.high_qual_7)	
	
	
********************************************************************************
********************************************************************************
**# APPENDIX TABLE A.7-Moderation Analysis with Theoretical Constructs
********************************************************************************
********************************************************************************
use "Data/achievement_data.dta", clear

//Achievement
local theory_driven  measurement_min1 incent_acct_min1 feedback_all
foreach i of local theory_driven{

//All Covariates
local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

//Math
qui reghdfe cs_mn_all 1.gen_st_tch_eval_imp##i.`i'  `cov' `ses_cov' `ach'  if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store `i'_pach_math
//ELA
qui reghdfe cs_mn_all 1.gen_st_tch_eval_imp##i.`i'  `cov' `ses_cov' `ach'  if subject=="rla" & st_trim_sample==1  & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store `i'_pach_ela
}

esttab  measurement_min1_pach_math incent_acct_min1_pach_math feedback_all_pach_math ///
		measurement_min1_pach_ela incent_acct_min1_pach_ela feedback_all_pach_ela ///
	using "Output/appendix_table_a7_panel_a_moderation_theory_constructs.csv", ///
	label ///
	nodepvars ///
	b(4) ///
	t(4) ///
	sfmt (4 0 0 0) ///
	replace  ///
	se(4) ///
	nomtitle ///
	nonote ///
	nogap ///
	stat(N, label("n") fmt(a3)) ///
	coeflabel(1.gen_st_tch_eval_imp "Eval" ///
	1.gen_st_tch_eval_imp#1.measurement_min1 "Eval X Measurement" ///
	1.gen_st_tch_eval_imp#1.incent_acct_min1 "Eval X Incent/Acct" ///
	1.gen_st_tch_eval_imp#1.feedback_all "Eval X Feedback/PD" ) ///
	keep(1.gen_st_tch_eval_imp 1.gen_st_tch_eval_imp#1.measurement_min1 1.gen_st_tch_eval_imp#1.incent_acct_min1 1.gen_st_tch_eval_imp#1.feedback_all)	
	
	
//Attainment
use "Data/attainment_data.dta", clear

local theory_driven  measurement_min1 incent_acct_min1 feedback_all
foreach i of local theory_driven{
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l hs_no_ged_a20_base_l ela_sd_naep_l math_sd_naep_l

reghdfe hs_no_ged_a20 i.gen_st_tch_eval_imp##i.`i' `covars' if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store hs_`i'_cov
}

local theory_driven  measurement_min1 incent_acct_min1 feedback_all
foreach i of local theory_driven{
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l enroll_pct_a22_base_l ela_sd_naep_l math_sd_naep_l

reghdfe enroll_pct_a22 i.gen_st_tch_eval_imp##i.`i' `covars' if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store en_`i'_cov
}

esttab  hs_measurement_min1_cov  hs_incent_acct_min1_cov  hs_feedback_all_cov  ///
	 en_measurement_min1_cov en_incent_acct_min1_cov  en_feedback_all_cov ///
	using "Output/appendix_table_a7_panel_b_moderation_theory_constructs.csv", ///
	label ///
	nodepvars ///
	b(4) ///
	t(4) ///
	sfmt (4 0 0 0) ///
	replace  ///
	se(4) ///
	nomtitle ///
	nonote ///
	nogap ///
	stat(N, label("n") fmt(a3)) ///
	coeflabel(1.gen_st_tch_eval_imp "Eval" ///
	1.gen_st_tch_eval_imp#1.measurement_min1 "Eval X Measurement" ///
	1.gen_st_tch_eval_imp#1.incent_acct_min1 "Eval X Incent/Acct" ///
	1.gen_st_tch_eval_imp#1.feedback_all "Eval X Feedback/PD" ) ///
	keep(1.gen_st_tch_eval_imp ///
	1.gen_st_tch_eval_imp#1.measurement_min1 ///
	1.gen_st_tch_eval_imp#1.incent_acct_min1 ///
	1.gen_st_tch_eval_imp#1.feedback_all )
	
********************************************************************************
********************************************************************************
**# APPENDIX TABLE A.8-Effects of Exemplar Evaluation Systems
********************************************************************************
********************************************************************************
use "Data/achievement_data.dta", clear

keep if inrange(gen_st_tch_rel,-4,4)
drop if fips==11

gen st_trim_sample_nctq=st_trim_sample
replace st_trim_sample_nctq=0 if gen_st_tch_rel==5

//Math
local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

reghdfe cs_mn_all tch_eval_no_nctq nctq if subject=="mth" & st_trim_sample_nctq==1 & st_math_smp==1, absorb(leaid year grade subject) cluster(fips)
estimate store twfe_ncov_mth

reghdfe cs_mn_all tch_eval_no_nctq nctq `cov' `ses_cov' `ach' if subject=="mth" & st_trim_sample_nctq==1 & st_math_smp==1, absorb(leaid year grade subject) cluster(fips)
estimate store twfe_pch_mth

estimate restore twfe_pch_mth
xlincom (tch_eval_no_nctq=tch_eval_no_nctq), post
estimate store nctq_naep_did_low

estimate restore twfe_pch_mth
xlincom (nctq_naep_did_high=nctq), post
estimate store nctq_naep_did_high

//ELA
local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

reghdfe cs_mn_all tch_eval_no_nctq nctq if subject=="rla" & st_trim_sample_nctq==1  & st_ela_smp==1, absorb(leaid year grade subject) cluster(fips)
estimate store twfe_ncov_ela

reghdfe cs_mn_all tch_eval_no_nctq nctq `cov' `ses_cov' `ach' if subject=="rla" & st_trim_sample_nctq==1  & st_ela_smp==1, absorb(leaid year grade subject) cluster(fips)
estimate store twfe_pch_ela

estimate restore twfe_pch_ela
xlincom (tch_eval_no_nctq=tch_eval_no_nctq), post
estimate store nctq_naep_did_low

estimate restore twfe_pch_ela
xlincom (nctq_naep_did_high=nctq), post
estimate store nctq_naep_did_high

use "Data/achievement_data.dta", clear

keep if inrange(gen_st_tch_rel,-4,4)

drop if fips==11

gen st_trim_sample_nctq=st_trim_sample
replace st_trim_sample_nctq=0 if gen_st_tch_rel==5

//Math
local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

reghdfe cs_mn_all no_nctq_0_to_1 no_nctq_2_to_3 nctq_0_to_1 nctq_2_to_3 if subject=="mth" & st_trim_sample_nctq==1 & st_math_smp==1, absorb(leaid year grade subject) cluster(fips)
estimate store nonlin_exmp_ncov_mth

reghdfe cs_mn_all no_nctq_0_to_1 no_nctq_2_to_3 nctq_0_to_1 nctq_2_to_3 `cov' `ses_cov' `ach' if subject=="mth" & st_trim_sample_nctq==1 & st_math_smp==1, absorb(leaid year grade subject) cluster(fips)
estimate store nonlin_exmp_pch_mth


//ELA
local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

reghdfe cs_mn_all no_nctq_0_to_1 no_nctq_2_to_3 nctq_0_to_1 nctq_2_to_3 if subject=="rla" & st_trim_sample_nctq==1  & st_ela_smp==1, absorb(leaid year grade subject) cluster(fips)
estimate store nonlin_exmp_ncov_ela

reghdfe cs_mn_all no_nctq_0_to_1 no_nctq_2_to_3 nctq_0_to_1 nctq_2_to_3 `cov' `ses_cov' `ach' if subject=="rla" & st_trim_sample_nctq==1  & st_ela_smp==1, absorb(leaid year grade subject) cluster(fips)
estimate store nonlin_exmp_pch_ela


esttab twfe_ncov_mth twfe_pch_mth twfe_ncov_ela twfe_pch_ela ///
	nonlin_exmp_ncov_mth nonlin_exmp_pch_mth nonlin_exmp_ncov_ela nonlin_exmp_pch_ela ///
	using "Output/appendix_table_a8_exemplar_system_effects.csv", ///
	label ///
	nodepvars ///
	b(4) ///
	t(4) ///
	sfmt (4 0 0 0) ///
	replace  ///
	se(4) ///
	nomtitle ///
	nonote ///
	nogap ///
	coeflabel(tch_eval_no_nctq "Non-Exemplar Eval" nctq "Exemplar" ///
	no_nctq_0_to_1 "Non-Exemplar Eval Post 0 to 1" no_nctq_2_to_3 "Non-Exemplar Eval Post 2 to 3" ///
	nctq_0_to_1 "Exemplar Post 0 to 1" nctq_2_to_3 "Exemplar Post 2 to 3") ///
	stat(N, label("n") fmt(a3)) ///
	keep(tch_eval_no_nctq nctq no_nctq_0_to_1 no_nctq_2_to_3 nctq_0_to_1 nctq_2_to_3)
	
********************************************************************************
********************************************************************************
**# APPENDIX TABLE A.9- Differential Effects for Sub-Groups
********************************************************************************
********************************************************************************
//Achievement
use "Data/achievement_data.dta", clear

//FRPL Rate
local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

//Math
qui reghdfe cs_mn_all i.gen_st_tch_eval_imp##c.perfl_base_09_s `cov' `ses_cov' `ach'  if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(fips year grade) cluster(fips)
estimate store mod_frpl_math
//ELA
qui reghdfe cs_mn_all i.gen_st_tch_eval_imp##c.perfl_base_09_s `cov' `ses_cov' `ach'  if subject=="rla" & st_trim_sample==1  & st_ela_smp==1, absorb(fips year grade) cluster(fips)
estimate store mod_frpl_ela

//Percent Black
local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l
//Math
qui reghdfe cs_mn_all i.gen_st_tch_eval_imp##c.perblk_base_09_s `cov' `ses_cov' `ach'  if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(fips year grade) cluster(fips)
estimate store mod_blk_math
//ELA
qui reghdfe cs_mn_all i.gen_st_tch_eval_imp##c.perblk_base_09_s `cov' `ses_cov' `ach'  if subject=="rla" & st_trim_sample==1  & st_ela_smp==1, absorb(fips year grade) cluster(fips)
estimate store mod_blk_ela

//Percent Hispanic
local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l
//Math
qui reghdfe cs_mn_all i.gen_st_tch_eval_imp##c.perhsp_base_09_s `cov' `ses_cov' `ach'  if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(fips year grade) cluster(fips)
estimate store mod_hsp_math
//ELA
qui reghdfe cs_mn_all i.gen_st_tch_eval_imp##c.perhsp_base_09_s `cov' `ses_cov' `ach'  if subject=="rla" & st_trim_sample==1  & st_ela_smp==1, absorb(fips year grade) cluster(fips)
estimate store mod_hsp_ela


esttab mod_frpl_math mod_blk_math mod_hsp_math ///
	using "Output/appendix_table_a9_panel_a_moderation.csv", ///
	label ///
	nodepvars ///
	b(4) ///
	t(4) ///
	sfmt (4 0 0 0) ///
	replace  ///
	se(4) ///
	nomtitle ///
	nonote ///
	nogap ///
	stat(N, label("n") fmt(a3)) ///
	coeflabel(1.gen_st_tch_eval_imp "Teacher Evaluation" ///
	 1.gen_st_tch_eval_imp#c.perfl_base_09_s "Teacher Evaluation X Percent FRPL" ///
	 1.gen_st_tch_eval_imp#c.perblk_base_09_s "Teacher Evaluation X Percent Black" ///
	 1.gen_st_tch_eval_imp#c.perhsp_base_09_s "Teacher Evaluation X Percent Hispanic" ) ///
	keep(1.gen_st_tch_eval_imp ///
	 1.gen_st_tch_eval_imp#c.perfl_base_09_s ///
	 1.gen_st_tch_eval_imp#c.perblk_base_09_s ///
	 1.gen_st_tch_eval_imp#c.perhsp_base_09_s)
	

esttab mod_frpl_ela mod_blk_ela mod_hsp_ela ///
	using "Output/appendix_table_a9_panel_b_moderation.csv", ///
	label ///
	nodepvars ///
	b(4) ///
	t(4) ///
	sfmt (4 0 0 0) ///
	replace  ///
	se(4) ///
	nomtitle ///
	nonote ///
	nogap ///
	stat(N, label("n") fmt(a3)) ///
	coeflabel(1.gen_st_tch_eval_imp "Teacher Evaluation" ///
	 1.gen_st_tch_eval_imp#c.perfl_base_09_s "Teacher Evaluation X Percent FRPL" ///
	 1.gen_st_tch_eval_imp#c.perblk_base_09_s "Teacher Evaluation X Percent Black" ///
	 1.gen_st_tch_eval_imp#c.perhsp_base_09_s "Teacher Evaluation X Percent Hispanic" ) ///
	keep(1.gen_st_tch_eval_imp ///
	 1.gen_st_tch_eval_imp#c.perfl_base_09_s ///
	 1.gen_st_tch_eval_imp#c.perblk_base_09_s ///
	 1.gen_st_tch_eval_imp#c.perhsp_base_09_s)
	 
	 
//Attainment
use "Data/attainment_data.dta", clear

local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l hs_no_ged_a20_base_l ela_sd_naep_l math_sd_naep_l
//FRPL Percent
reghdfe hs_no_ged_a20 i.gen_st_tch_eval_imp##c.frpl_pct_s `covars' if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store hs_het_frpl
//Black Percent
reghdfe hs_no_ged_a20 i.gen_st_tch_eval_imp##c.black_pct_s `covars' if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store hs_het_blk
//Hispanic Percent
reghdfe hs_no_ged_a20 i.gen_st_tch_eval_imp##c.hisp_pct_s `covars' if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store hs_het_hisp

local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l enroll_pct_a22_base_l ela_sd_naep_l math_sd_naep_l
//FRPL Percent
reghdfe enroll_pct_a22 i.gen_st_tch_eval_imp##c.frpl_pct_s `covars' if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store cs_het_frpl
//Black Percent
reghdfe enroll_pct_a22 i.gen_st_tch_eval_imp##c.black_pct_s `covars' if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store cs_het_blk
//Hispanic Percent
reghdfe enroll_pct_a22 i.gen_st_tch_eval_imp##c.hisp_pct_s `covars' if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store cs_het_hisp
	
esttab hs_het_frpl hs_het_blk hs_het_hisp ///
	using "Output/appendix_table_a9_panel_c_moderation.csv", ///
	label ///
	nodepvars ///
	b(4) ///
	t(4) ///
	sfmt (4 0 0 0) ///
	replace  ///
	se(4) ///
	nomtitle ///
	nonote ///
	nogap ///
	stat(N, label("n") fmt(a3)) ///
	coeflabel(1.gen_st_tch_eval_imp "Teacher Evaluation" ///
	 1.gen_st_tch_eval_imp#c.perfl_base_09_s "Teacher Evaluation X Percent FRPL" ///
	 1.gen_st_tch_eval_imp#c.perblk_base_09_s "Teacher Evaluation X Percent Black" ///
	 1.gen_st_tch_eval_imp#c.perhsp_base_09_s "Teacher Evaluation X Percent Hispanic" ) ///
	keep(1.gen_st_tch_eval_imp ///
	1.gen_st_tch_eval_imp#c.frpl_pct_s ///
	1.gen_st_tch_eval_imp#c.black_pct_s ///
	1.gen_st_tch_eval_imp#c.hisp_pct_s)

esttab cs_het_frpl cs_het_blk cs_het_hisp ///
	using "Output/appendix_table_a9_panel_d_moderation.csv", ///
	label ///
	nodepvars ///
	b(4) ///
	t(4) ///
	sfmt (4 0 0 0) ///
	replace  ///
	se(4) ///
	nomtitle ///
	nonote ///
	nogap ///
	stat(N, label("n") fmt(a3)) ///
	coeflabel(1.gen_st_tch_eval_imp "Teacher Evaluation" ///
	 1.gen_st_tch_eval_imp#c.perfl_base_09_s "Teacher Evaluation X Percent FRPL" ///
	 1.gen_st_tch_eval_imp#c.perblk_base_09_s "Teacher Evaluation X Percent Black" ///
	 1.gen_st_tch_eval_imp#c.perhsp_base_09_s "Teacher Evaluation X Percent Hispanic" ) ///
	keep(1.gen_st_tch_eval_imp ///
	1.gen_st_tch_eval_imp#c.frpl_pct_s ///
	1.gen_st_tch_eval_imp#c.black_pct_s ///
	1.gen_st_tch_eval_imp#c.hisp_pct_s)
	
********************************************************************************
********************************************************************************
**# APPENDIX TABLE A.10-Controlling for State-Specific Linear Trends
********************************************************************************
********************************************************************************
//Achievement
use "Data/achievement_data.dta", clear

//Math
qui reghdfe cs_mn_all gen_st_tch_eval_imp $state_trends if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb( leaid grade year) cluster(fips)
estimate store s_trend_st_math
//ELA
qui reghdfe cs_mn_all gen_st_tch_eval_imp $state_trends if subject=="rla" & st_trim_sample==1 & st_ela_smp==1, absorb( leaid grade year) cluster(fips)
estimate store s_trend_st_ela

//All Covariates
local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

//Math
qui reghdfe cs_mn_all gen_st_tch_eval_imp `cov' `ses_cov' `ach' $state_trends if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb( leaid grade year) cluster(fips)
estimate store s_trend_pach_st_math
//ELA
qui reghdfe cs_mn_all gen_st_tch_eval_imp `cov' `ses_cov' `ach' $state_trends if subject=="rla" & st_trim_sample==1  & st_ela_smp==1, absorb( leaid grade year) cluster(fips)
estimate store s_trend_pach_st_ela

//Attainment
use "Data/attainment_data.dta", clear

areg hs_no_ged_a20 gen_st_tch_eval_imp $state_trends i.year if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips)  cluster(fips)
	estimate store hs_no_ged_a20_strends
areg enroll_pct_a22 gen_st_tch_eval_imp $state_trends i.year if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips) cluster(fips)
	estimate store enroll_pct_a22_strends

esttab s_trend_st_math s_trend_pach_st_math s_trend_st_ela s_trend_pach_st_ela hs_no_ged_a20_strends enroll_pct_a22_strends ///
	using "Output/appendix_table_a10_state_specific_linear_trends.csv", ///
	label ///
	nodepvars ///
	b(4) ///
	t(4) ///
	sfmt (4 0 0 0) ///
	replace  ///
	se(4) ///
	nomtitle ///
	nonote ///
	nogap ///
	stat(N, label("n") fmt(a3)) ///
	coeflabel(gen_st_tch_eval_imp "Teacher Evaluation") ///
	keep(gen_st_tch_eval_imp)

********************************************************************************
********************************************************************************
**# APPENDIX TABLE A.11-Controlling for Time Varying State Policies
********************************************************************************
********************************************************************************
//Achievemet
use "Data/achievement_data.dta", clear

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

local policies eliminate_tenure increase_prob_period weaken_col_bargain eliminate_union_due won_rttt imp_cc basic_skills_licensing_test content_area_license ped_knowledge_test common_assessments innovativeschoolsauth innovativeschoolsbuild innovativeschoolsnumber lowachieve_intervene pathwaysroutes prepprogram taxcredit2 testing_exitexam testing_third_gr sfr

//Math
qui reghdfe cs_mn_all gen_st_tch_eval_imp `policies'  if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store policies_st_math
//ELA
qui reghdfe cs_mn_all gen_st_tch_eval_imp `policies'   if subject=="rla" & st_trim_sample==1  & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store policies_st_ela


//Math
qui reghdfe cs_mn_all gen_st_tch_eval_imp `policies' `cov' `ses_cov' `ach' if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store policies_pach_math
//ELA
qui reghdfe cs_mn_all gen_st_tch_eval_imp `policies' `cov' `ses_cov' `ach'  if subject=="rla" & st_trim_sample==1  & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store policies_pach_st_ela

//Attainment
use "Data/attainment_data.dta", clear

local policies eliminate_tenure increase_prob_period weaken_col_bargain eliminate_union_due won_rttt imp_cc basic_skills_licensing_test content_area_license ped_knowledge_test common_assessments innovativeschoolsauth innovativeschoolsbuild innovativeschoolsnumber lowachieve_intervene pathwaysroutes prepprogram taxcredit2 testing_exitexam testing_third_gr sfr

local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l hs_no_ged_a20_base_l ela_sd_naep_l math_sd_naep_l

reghdfe hs_no_ged_a20 gen_st_tch_eval_imp `policies' if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store hs_no_ged_a20_polcies
reghdfe hs_no_ged_a20 gen_st_tch_eval_imp `covars' `policies' if hs_grad_a20_smp==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store hs_no_ged_a20_polcies_cov
	
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l enroll_pct_a22_base_l ela_sd_naep_l math_sd_naep_l
reghdfe enroll_pct_a22 gen_st_tch_eval_imp `policies' if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year) cluster(fips)
	estimate store enroll_pct_a22_pol
reghdfe enroll_pct_a22 gen_st_tch_eval_imp `covars' `policies' if enroll_pct_a22_smp==1 & trim_sample==0, absorb(fips year) cluster(fips)
	estimate store enroll_pct_a22_pol_covar

	
esttab policies_st_math policies_pach_math policies_st_ela policies_pach_st_ela ///
	hs_no_ged_a20_polcies hs_no_ged_a20_polcies_cov enroll_pct_a22_pol enroll_pct_a22_pol_covar ///
	using "Output/appendix_table_a11_controlling_time_varying_policies.csv", ///
	label ///
	nodepvars ///
	b(4) ///
	t(4) ///
	sfmt (4 0 0 0) ///
	replace  ///
	se(4) ///
	nomtitle ///
	nonote ///
	nogap ///
	stat(N, label("n") fmt(a3)) ///
	coeflabel(gen_st_tch_eval_imp "Teacher Evaluation") ///
	keep(gen_st_tch_eval_imp)
	
********************************************************************************
********************************************************************************
**# APPENDIX TABLE A.12- Replicating results using the Low-Stakes NAEP Assessment
********************************************************************************
********************************************************************************
/*
Created using NAEP Restricted Data. Regression analysis code included for reference

qui reghdfe pv_1 gen_st_tch_eval_imp if inlist(data_set,1,2) & st_trim_sample==1 & st_math_smp==1 [pw=origwt], absorb(leaid_num data_set year) cluster(fips)

qui reghdfe pv_1 gen_st_tch_eval_imp if inlist(data_set,3,4) & st_trim_sample==1 & st_ela_smp==1  [pw=origwt], absorb(leaid_num data_set year) cluster(fips)

local cov sex iep lep slunch race_1 race_2 race_3 race_4 race_5 race_6 ///
	modal_grade1 modal_grade3 ///
	 lrg_city_base_03_l totenrl_base_03_l stud_tch_ratio_base_03_l ppe_inst_base_03_l
local ses_cov perc_5_17_pov_base_03_l gdp_base_03_l unemp_base_03_l
local ach year_X_pv_1_d12_sbase_03 year_X_pv_1_d34_sbase_03 madeayp2

qui reghdfe pv_1 gen_st_tch_eval_imp `cov' `ses_cov' `ach' if inlist(data_set,1,2) & st_trim_sample==1 & st_math_smp==1 [pw=origwt], absorb(leaid_num data_set year) cluster(fips)

qui reghdfe pv_1 gen_st_tch_eval_imp `cov' `ses_cov' `ach' if inlist(data_set,3,4) & st_trim_sample==1 & st_ela_smp==1 [pw=origwt], absorb(leaid_num data_set year) cluster(fips)
*/

********************************************************************************
********************************************************************************
**# APPENDIX TABLE A.13- Teacher Evaluation Effect on Salary
********************************************************************************
********************************************************************************
use "Data/teacher_salary_data.dta", clear

local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l ravg_sal_base_l ela_sd_naep_l math_sd_naep_l

reghdfe ravg_sal gen_st_tch_eval_imp `covars' if trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store ravg_sal_cov
reghdfe ravg_sal gen_st_tch_eval_imp if _est_ravg_sal_cov==1 & trim_sample==0, absorb(fips year)  cluster(fips)
	estimate store ravg_sal_ncov

esttab ravg_sal_ncov ravg_sal_cov ///
	using "Output/appendix_table_a13_teacher_salaries.csv", ///
	label ///
	nodepvars ///
	b(4) ///
	t(4) ///
	sfmt (4 0 0 0) ///
	replace  ///
	se(4) ///
	nomtitle ///
	nonote ///
	nogap ///
	stat(N, label("n") fmt(a3)) ///
	coeflabel(gen_st_tch_eval_imp "Teacher Evaluation") ///
	keep(gen_st_tch_eval_imp)
	
********************************************************************************
********************************************************************************
**# APPENDIX TABLE A.14- Bayesian Posterior Mean and Standard Error Estimates
********************************************************************************
********************************************************************************
*See Excel Workbook "Bayesian Analysis.xlsx"

********************************************************************************
********************************************************************************
**# APPENDIX FIGURE A.1- Implementation of Evaluation Reforms by Year
********************************************************************************
********************************************************************************
import excel "Data/treatment_data.xlsx", sheet("st_data") cellrange(A1:C52) firstrow clear

histogram (gen_st_tch_eval_imp_yr), yline(5 10 15, lp(solid) lc(black) lwid(vthin) )  ///
	graphregion(color(white)) bgcolor(white) fcolor(gs10) bcolor(black) ///
	freq discrete xlabel(2009(1)2017) xtitle("State Implementation Year") scheme(s2color)
	graph export "Output/appendix_figure_a1_implementation_by_year.pdf", as(pdf) replace


********************************************************************************
********************************************************************************
**# APPENDIX FIGURE A.2-Event Study: Attainment Measured at Alternate Ages
********************************************************************************
********************************************************************************
use "Data/attainment_data.dta", clear

local event_dummies gen_st_tch_rel_5-gen_st_tch_rel_8 gen_st_tch_rel_10-gen_st_tch_rel_18 gen_st_tch_rel_9 ref
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l hs_no_ged_a20_base_l ela_sd_naep_l math_sd_naep_l
qui reghdfe hs_grad_a18 `event_dummies' `covars' if hs_grad_a20_smp==1, absorb(fips year)  cluster(fips)
	estimate store hs_grad_a18_event_cov
	
	
coefplot (hs_grad_a18_event_cov, mlcolor(black) mfcolor(black)), ///
vert rename(gen_st_tch_rel_5="-5" ///
			gen_st_tch_rel_6="-4" ///
			gen_st_tch_rel_7="-3" ///
			gen_st_tch_rel_8="-2" ///
			gen_st_tch_rel_9="-1" ///
			gen_st_tch_rel_10="0" ///
			gen_st_tch_rel_11="1" ///
			gen_st_tch_rel_12="2" ///
			gen_st_tch_rel_13="3" ///
			gen_st_tch_rel_14="4" ///
			gen_st_tch_rel_15="5" ///
			gen_st_tch_rel_16="6" ///
			gen_st_tch_rel_17="7" ///
			gen_st_tch_rel_18="8") ///
order("-5" "-4" "-3" "-2" "-1" "0" "1" "2" "3" "4" "5" "6" "7" "8") ///
xtitle("State Teacher Eval Implemented (Year)") xline(5, lp(solid) lcolor(black)) ///
ytitle("% HS Graduates") yscale(range(-5 5)) levels(95) /// ///
ylabel(-8 "8%" -7 "7%" -6 "6%" -5 "-5%" -4 "-4%" -3 "-3%" -2 "-2%" -1 "-1%" 0 "0%"  1 "1%" 2 "2%" 3 "3%" 4 "4%" 5 "5%" 6 "6%" 7 "7%" 8 "8%", ///
angle(45) labsize(small) labc(black)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) lcol(black)) ///
yline(0, lp(solid) lc(black)) ///
yline(-8 -7 -6 -5 -4 -3 -2 -1 1 2 3 4 5 6 7 8, lp(solid) lc(gs12) lwid(vthin)) ///
keep(gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_8 ///
		   gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 ///
		   gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_15 gen_st_tch_rel_16 gen_st_tch_rel_17 gen_st_tch_rel_18) ///
scheme(s2color)
		   
graph export "Output/appendix_figure_a2_panel_a_alt_age.pdf", as(pdf) replace

local event_dummies gen_st_tch_rel_5-gen_st_tch_rel_8 gen_st_tch_rel_10-gen_st_tch_rel_18 gen_st_tch_rel_9 ref
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l enroll_pct_a20_base_l ela_sd_naep_l math_sd_naep_l
qui reghdfe enroll_pct_a20 `event_dummies' `covars' if enroll_pct_a22_smp==1, absorb(fips year) cluster(fips)
	estimate store enroll_pct_event_cov_20
	
coefplot (enroll_pct_event_cov_20, mlcolor(black) mfcolor(black)), ///
vert rename(gen_st_tch_rel_5="-5" ///
			gen_st_tch_rel_6="-4" ///
			gen_st_tch_rel_7="-3" ///
			gen_st_tch_rel_8="-2" ///
			gen_st_tch_rel_9="-1" ///
			gen_st_tch_rel_10="0" ///
			gen_st_tch_rel_11="1" ///
			gen_st_tch_rel_12="2" ///
			gen_st_tch_rel_13="3" ///
			gen_st_tch_rel_14="4" ///
			gen_st_tch_rel_15="5" ///
			gen_st_tch_rel_16="6" ///
			gen_st_tch_rel_17="7" ///
			gen_st_tch_rel_18="8") ///
order("-5" "-4" "-3" "-2" "-1" "0" "1" "2" "3" "4" "5" "6" "7" "8") ///
xtitle("State Teacher Eval Implemented (Year)") xline(5, lp(solid) lcolor(black)) ///
ytitle("% College Enrollment") yscale(range(-5 5)) levels(95) /// ///
ylabel(-8 "8%" -7 "7%" -6 "6%" -5 "-5%" -4 "-4%" -3 "-3%" -2 "-2%" -1 "-1%" 0 "0%"  1 "1%" 2 "2%" 3 "3%" 4 "4%" 5 "5%" 6 "6%" 7 "7%" 8 "8%", ///
angle(45) labsize(small) labc(black)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) lcol(black)) ///
yline(0, lp(solid) lc(black)) ///
yline(-8 -7 -6 -5 -4 -3 -2 -1 1 2 3 4 5 6 7 8, lp(solid) lc(gs12) lwid(vthin)) ///
keep(gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_8 ///
		   gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 ///
		   gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_15 gen_st_tch_rel_16 gen_st_tch_rel_17 gen_st_tch_rel_18) ///
scheme(s2color)
		   
graph export "Output/appendix_figure_a2_panel_b_alt_age.pdf", as(pdf) replace


********************************************************************************
********************************************************************************
**# APPENDIX FIGURE A.3- Event Study: Untrimmed Effects on Achievement and Attainment
********************************************************************************
********************************************************************************
use "Data/achievement_data.dta", clear

//Achievement
local st_event_dummies gen_st_tch_rel_1 gen_st_tch_rel_2 gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_15 gen_st_tch_rel_8

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

//Math
qui reghdfe cs_mn_all `st_event_dummies' `cov' `ses_cov' `ach'  if subject=="mth" & fips~=11, absorb(leaid year grade) cluster(fips)
estimate store ev_utr_math
//ELA
qui reghdfe cs_mn_all `st_event_dummies' `cov' `ses_cov' `ach'  if subject=="rla" & fips~=11, absorb(leaid year grade) cluster(fips)
estimate store ev_utr_ela


//Math
coefplot (ev_utr_math, mlcolor(black) mfcolor(black)), ///
vert rename(gen_st_tch_rel_1="-8" gen_st_tch_rel_2="-7" gen_st_tch_rel_3="-6" ///
gen_st_tch_rel_4="-5" gen_st_tch_rel_5="-4" gen_st_tch_rel_6="-3" ///
gen_st_tch_rel_7="-2" gen_st_tch_rel_8="-1" gen_st_tch_rel_9="0" gen_st_tch_rel_10="1" ///
gen_st_tch_rel_11="2" gen_st_tch_rel_12="3" gen_st_tch_rel_13="4" ///
gen_st_tch_rel_14="5" gen_st_tch_rel_15="6") ///
order("-8" "-7" "-6" "-5" "-4" "-3" "-2" "-1" "0" "1" "2" "3" "4" "5" "6") ///
xtitle("State General Teacher Eval Implemented (Year)") xline(8, lp(solid) lcolor(black)) xlabel(, labsize(small)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) color(black)) ///
ytitle("Math Score SD") yscale(range(-.1 .1)) ylabel(-.1(.02).1, labsize(small)) levels(95) ///
yline(0, lp(solid) lc(black)) ///
yline(-0.10 -0.08 -0.06 -0.04 -0.02 0.02 0.04 0.06 0.08 0.10, lp(solid) lc(gs12) lwid(vthin)) ///
keep(gen_st_tch_rel_1 gen_st_tch_rel_2 gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 ///
gen_st_tch_rel_8 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 ///
gen_st_tch_rel_14 gen_st_tch_rel_15 gen_st_tch_rel_16)
graph export "Output/appendix_figure_a3_panel_a_math_untrimmed.pdf", as(pdf) replace

//ELA
coefplot (ev_utr_ela, mlcolor(black) mfcolor(black)), ///
vert rename(gen_st_tch_rel_1="-8" gen_st_tch_rel_2="-7" gen_st_tch_rel_3="-6" ///
gen_st_tch_rel_4="-5" gen_st_tch_rel_5="-4" gen_st_tch_rel_6="-3" ///
gen_st_tch_rel_7="-2" gen_st_tch_rel_8="-1" gen_st_tch_rel_9="0" gen_st_tch_rel_10="1" ///
gen_st_tch_rel_11="2" gen_st_tch_rel_12="3" gen_st_tch_rel_13="4" ///
gen_st_tch_rel_14="5" gen_st_tch_rel_15="6") ///
order("-8" "-7" "-6" "-5" "-4" "-3" "-2" "-1" "0" "1" "2" "3" "4" "5" "6") ///
xtitle("State General Teacher Eval Implemented (Year)") xline(8, lp(solid) lcolor(black)) xlabel(, labsize(small)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) color(black)) ///
ytitle("ELA Score SD") yscale(range(-.1 .1)) ylabel(-.1(.02).1, labsize(small)) levels(95) ///
yline(0, lp(solid) lc(black)) ///
yline(-0.10 -0.08 -0.06 -0.04 -0.02 0.02 0.04 0.06 0.08 0.10, lp(solid) lc(gs12) lwid(vthin)) ///
keep(gen_st_tch_rel_1 gen_st_tch_rel_2 gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 ///
gen_st_tch_rel_8 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 ///
gen_st_tch_rel_14 gen_st_tch_rel_15)
graph export "Output/appendix_figure_a3_panel_a_ela_untrimmed.pdf", as(pdf) replace

//Attainment
use "Data/attainment_data.dta", clear
drop if fips==11 //Dropping DC here because the most proximate periods are just DC
//Event with Covariates X Year Trend
local event_dummies gen_st_tch_rel_1-gen_st_tch_rel_8 gen_st_tch_rel_10-gen_st_tch_rel_20 gen_st_tch_rel_9 ref
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l hs_no_ged_a20_base_l ela_sd_naep_l math_sd_naep_l
reghdfe hs_no_ged_a20 `event_dummies' `covars', absorb(fips year)  cluster(fips)
	estimate store utr_hs_no_ged_a20_event_cov
//Coef Plot with Covariates
coefplot (utr_hs_no_ged_a20_event_cov, mlcolor(black) mfcolor(black)), ///
vert rename(gen_st_tch_rel_1="-9" ///
			gen_st_tch_rel_2="-8" ///
			gen_st_tch_rel_3="-7" ///
			gen_st_tch_rel_4="-6" ///
			gen_st_tch_rel_5="-5" ///
			gen_st_tch_rel_6="-4" ///
			gen_st_tch_rel_7="-3" ///
			gen_st_tch_rel_8="-2" ///
			gen_st_tch_rel_9="-1" ///
			gen_st_tch_rel_10="0" ///
			gen_st_tch_rel_11="1" ///
			gen_st_tch_rel_12="2" ///
			gen_st_tch_rel_13="3" ///
			gen_st_tch_rel_14="4" ///
			gen_st_tch_rel_15="5" ///
			gen_st_tch_rel_16="6" ///
			gen_st_tch_rel_17="7" ///
			gen_st_tch_rel_18="8" ///
			gen_st_tch_rel_19="9" ///
			gen_st_tch_rel_20="10") ///
order("-9" "-8" "-7" "-6" "-5" "-4" "-3" "-2" "-1" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "10") ///
xtitle("State Teacher Eval Implemented (Year)") xline(9, lp(solid) lcolor(black)) ///
ytitle("% HS Graduates") yscale(range(-5 5)) levels(95) /// ///
ylabel(-10 "-10%" -9 "-9%" -8 "-8%" -7 "-7%" -6 "-6%" -5 "-5%" -4 "-4%" -3 "-3%" -2 "-2%" -1 "-1%" ///
0 "0%"  1 "1%" 2 "2%" 3 "3%" 4 "4%" 5 "5%" 6 "6%" 7 "7%" 8 "8%" 9 "9%" 10 "10%", ///
angle(45) labsize(small) labc(black)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) color(black)) ///
yline(0, lp(solid) lc(black)) ///
yline(-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 1 2 3 4 5 6 7 8 9 10, lp(solid) lc(gs12) lwid(vthin)) ///
keep(gen_st_tch_rel_1 gen_st_tch_rel_2 gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 ///
	 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_8 ///
     gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 ///
	 gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_15 gen_st_tch_rel_16 gen_st_tch_rel_17 ///
	 gen_st_tch_rel_18 gen_st_tch_rel_19 gen_st_tch_rel_20)
graph export "Output/appendix_figure_a3_panel_b_hs_grad_untrimmed.pdf", as(pdf) replace

//Event with Covariates X Year Trend
local event_dummies gen_st_tch_rel_1-gen_st_tch_rel_8 gen_st_tch_rel_10-gen_st_tch_rel_20 gen_st_tch_rel_9 ref
local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l tot_enrl_l urban_l gdp_st_l enroll_pct_a22_base_l ela_sd_naep_l math_sd_naep_l
reghdfe enroll_pct_a22 `event_dummies' `covars', absorb(fips year) cluster(fips)
	estimate store utr_enrl_pct_a22_event_cov

//Coef Plot with Covariates
coefplot (utr_enrl_pct_a22_event_cov, mlcolor(black) mfcolor(black)), ///
vert rename(gen_st_tch_rel_1="-9" ///
			gen_st_tch_rel_2="-8" ///
			gen_st_tch_rel_3="-7" ///
			gen_st_tch_rel_4="-6" ///
			gen_st_tch_rel_5="-5" ///
			gen_st_tch_rel_6="-4" ///
			gen_st_tch_rel_7="-3" ///
			gen_st_tch_rel_8="-2" ///
			gen_st_tch_rel_9="-1" ///
			gen_st_tch_rel_10="0" ///
			gen_st_tch_rel_11="1" ///
			gen_st_tch_rel_12="2" ///
			gen_st_tch_rel_13="3" ///
			gen_st_tch_rel_14="4" ///
			gen_st_tch_rel_15="5" ///
			gen_st_tch_rel_16="6" ///
			gen_st_tch_rel_17="7" ///
			gen_st_tch_rel_18="8" ///
			gen_st_tch_rel_19="9" ///
			gen_st_tch_rel_20="10") ///
order("-9" "-8" "-7" "-6" "-5" "-4" "-3" "-2" "-1" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "10") ///
xtitle("State Teacher Eval Implemented (Year)") xline(9, lp(solid) lcolor(black)) ///
ytitle("% College Enrollment") yscale(range(-5 5)) levels(95) /// ///
ylabel(-10 "-10%" -9 "-9%" -8 "-8%" -7 "-7%" -6 "-6%" -5 "-5%" -4 "-4%" -3 "-3%" -2 "-2%" -1 "-1%" ///
0 "0%"  1 "1%" 2 "2%" 3 "3%" 4 "4%" 5 "5%" 6 "6%" 7 "7%" 8 "8%" 9 "9%" 10 "10%", ///
angle(45) labsize(small) labc(black)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) color(black)) ///
yline(0, lp(solid) lc(black)) ///
yline(-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 1 2 3 4 5 6 7 8 9 10, lp(solid) lc(gs12) lwid(vthin)) ///
keep(gen_st_tch_rel_1 gen_st_tch_rel_2 gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 ///
	 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_8 ///
     gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 ///
	 gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_15 gen_st_tch_rel_16 gen_st_tch_rel_17 ///
	 gen_st_tch_rel_18 gen_st_tch_rel_19 gen_st_tch_rel_20)
graph export "Output/appendix_figure_a3_panel_b_col_enrl_untrimmed.pdf", as(pdf) replace

********************************************************************************
********************************************************************************
**# APPENDIX FIGURE A.4-Event Study Rigorous Design (Index 8 to 10)
********************************************************************************
********************************************************************************
use "Data/achievement_data.dta", clear

local st_event_dummies gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_8

local st_event_dummies_all gen_st_tch_rel_3_h8 gen_st_tch_rel_4_h8 gen_st_tch_rel_5_h8 gen_st_tch_rel_6_h8 gen_st_tch_rel_7_h8 gen_st_tch_rel_9_h8 gen_st_tch_rel_10_h8 gen_st_tch_rel_11_h8 gen_st_tch_rel_12_h8 gen_st_tch_rel_13_h8 gen_st_tch_rel_14_h8 gen_st_tch_rel_8_h8

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

//Math
qui reghdfe cs_mn_all `st_event_dummies'  `st_event_dummies_all' ///
`cov' `ses_cov' `ach' ///
 if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid year grade) cluster(fips)
estimate store h8_ev_pch_math

estimate restore h8_ev_pch_math
xlincom (rel_3=gen_st_tch_rel_3) ///
		(rel_4=gen_st_tch_rel_4) ///
		(rel_5=gen_st_tch_rel_5) ///
		(rel_6=gen_st_tch_rel_6) ///
		(rel_7=gen_st_tch_rel_7) ///
		(rel_8=gen_st_tch_rel_8) ///
		(rel_9=gen_st_tch_rel_9) ///
		(rel_10=gen_st_tch_rel_10) ///
		(rel_11=gen_st_tch_rel_11) ///
		(rel_12=gen_st_tch_rel_12) ///
		(rel_13=gen_st_tch_rel_13) ///
		(rel_14=gen_st_tch_rel_14), post
estimate store ev_h8_low_math

estimate restore h8_ev_pch_math
xlincom (rel_3=gen_st_tch_rel_3+gen_st_tch_rel_3_h8) ///
		(rel_4=gen_st_tch_rel_4+gen_st_tch_rel_4_h8) ///
		(rel_5=gen_st_tch_rel_5+gen_st_tch_rel_5_h8) ///
		(rel_6=gen_st_tch_rel_6+gen_st_tch_rel_6_h8) ///
		(rel_7=gen_st_tch_rel_7+gen_st_tch_rel_7_h8) ///
		(rel_8=gen_st_tch_rel_8+gen_st_tch_rel_8_h8) ///
		(rel_9=gen_st_tch_rel_9+gen_st_tch_rel_9_h8) ///
		(rel_10=gen_st_tch_rel_10+gen_st_tch_rel_10_h8) ///
		(rel_11=gen_st_tch_rel_11+gen_st_tch_rel_11_h8) ///
		(rel_12=gen_st_tch_rel_12+gen_st_tch_rel_12_h8) ///
		(rel_13=gen_st_tch_rel_13+gen_st_tch_rel_13_h8) ///
		(rel_14=gen_st_tch_rel_14+gen_st_tch_rel_14_h8), post
estimate store ev_h8_high_math

coefplot (ev_h8_low_math,  msymbol(O) mlcolor(black) mfcolor(black) ciopts(recast(rcap) color(black)) ) ///
		 (ev_h8_high_math, msymbol(O) mlcolor(gs7*.5) mfcolor(gs7*.5) ciopts(recast(rcap) color(gs7*.5))), vert ///
coeflabel(rel_3="-6" rel_4="-5" rel_5="-4" rel_6="-3" rel_7="-2" rel_8="-1" rel_9="0" rel_10="1" rel_11="2" rel_12="3" rel_13="4" rel_13="4" rel_14="5") ///
xtitle("Years Relative to Teacher Evaluation") xline(6, lp(solid) lcolor(gs3)) xlabel(, labsize(small)) ///
graphregion(color(white)) bgcolor(white) omitted ciopts(recast(rcap) lcol(black)) ///
ytitle("Math Effect SD") ///
yscale(range(-.1 .1)) ylabel(-.1(.02).1, labsize(small)) levels(95) ///
yline(-.1 -.08 -.06 -.04 -.02 0 .02 .04 .06 .08 .1, lp(solid) lc(gs12) lwid(vthin)) ///
yline(0, lp(dash) lc(black)) ///
legend(order(2 "Tch Eval" 4 "Tch Eval + (Index >7)") pos(6) row(1))
			 
graph export "Output/appendix_figure_a4_rigorous_eval_event_study_math.pdf", as(pdf) replace

//ELA
local st_event_dummies gen_st_tch_rel_3 gen_st_tch_rel_4 gen_st_tch_rel_5 gen_st_tch_rel_6 gen_st_tch_rel_7 gen_st_tch_rel_9 gen_st_tch_rel_10 gen_st_tch_rel_11 gen_st_tch_rel_12 gen_st_tch_rel_13 gen_st_tch_rel_14 gen_st_tch_rel_8

local st_event_dummies_all gen_st_tch_rel_3_h8 gen_st_tch_rel_4_h8 gen_st_tch_rel_5_h8 gen_st_tch_rel_6_h8 gen_st_tch_rel_7_h8 gen_st_tch_rel_9_h8 gen_st_tch_rel_10_h8 gen_st_tch_rel_11_h8 gen_st_tch_rel_12_h8 gen_st_tch_rel_13_h8 gen_st_tch_rel_14_h8 gen_st_tch_rel_8_h8

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

qui reghdfe cs_mn_all `st_event_dummies' `st_event_dummies_all' ///
`cov' `ses_cov' `ach' ///
 if subject=="rla" & st_trim_sample==1 & st_ela_smp==1, absorb(leaid year grade) cluster(fips)
estimate store h8_ev_pch_ela

estimate restore h8_ev_pch_ela
xlincom (rel_3=gen_st_tch_rel_3) ///
		(rel_4=gen_st_tch_rel_4) ///
		(rel_5=gen_st_tch_rel_5) ///
		(rel_6=gen_st_tch_rel_6) ///
		(rel_7=gen_st_tch_rel_7) ///
		(rel_8=gen_st_tch_rel_8) ///
		(rel_9=gen_st_tch_rel_9) ///
		(rel_10=gen_st_tch_rel_10) ///
		(rel_11=gen_st_tch_rel_11) ///
		(rel_12=gen_st_tch_rel_12) ///
		(rel_13=gen_st_tch_rel_13) ///
		(rel_14=gen_st_tch_rel_14), post
estimate store ev_h8_low_ela

estimate restore h8_ev_pch_ela
xlincom (rel_3=gen_st_tch_rel_3+gen_st_tch_rel_3_h8) ///
		(rel_4=gen_st_tch_rel_4+gen_st_tch_rel_4_h8) ///
		(rel_5=gen_st_tch_rel_5+gen_st_tch_rel_5_h8) ///
		(rel_6=gen_st_tch_rel_6+gen_st_tch_rel_6_h8) ///
		(rel_7=gen_st_tch_rel_7+gen_st_tch_rel_7_h8) ///
		(rel_8=gen_st_tch_rel_8+gen_st_tch_rel_8_h8) ///
		(rel_9=gen_st_tch_rel_9+gen_st_tch_rel_9_h8) ///
		(rel_10=gen_st_tch_rel_10+gen_st_tch_rel_10_h8) ///
		(rel_11=gen_st_tch_rel_11+gen_st_tch_rel_11_h8) ///
		(rel_12=gen_st_tch_rel_12+gen_st_tch_rel_12_h8) ///
		(rel_13=gen_st_tch_rel_13+gen_st_tch_rel_13_h8) ///
		(rel_14=gen_st_tch_rel_14+gen_st_tch_rel_14_h8), post
estimate store ev_h8_high_ela

coefplot (ev_h8_low_ela,  msymbol(O) mlcolor(black) mfcolor(black) ciopts(recast(rcap) color(black)) ) ///
		 (ev_h8_high_ela, msymbol(O) mlcolor(gs7*.5) mfcolor(gs7*.5) ciopts(recast(rcap) color(gs7*.5))), vert ///
coeflabel(rel_3="-6" rel_4="-5" rel_5="-4" rel_6="-3" rel_7="-2" rel_8="-1" rel_9="0" rel_10="1" rel_11="2" rel_12="3" rel_13="4" rel_14="5") ///
xtitle("Years Relative to Teacher Evaluation") xline(6, lp(solid) lcolor(gs3)) xlabel(, labsize(small)) ///
graphregion(color(white)) bgcolor(white) omitted ///
ytitle("ELA Effect SD") ///
yscale(range(-.1 .1)) ylabel(-.1(.02).1, labsize(small)) levels(95) ///
yline(-.1 -.08 -.06 -.04 -.02 0 .02 .04 .06 .08 .1, lp(solid) lc(gs12) lwid(vthin)) ///
yline(0, lp(dash) lc(black)) ///
legend(order(2 "Tch Eval" 4 "Tch Eval + (Index >7)") pos(6) row(1))

graph export "Output/appendix_figure_a4_rigorous_eval_event_study_ela.pdf", as(pdf) replace

********************************************************************************
********************************************************************************
**# APPENDIX TABLE B.1- Teacher Evaluation Reform Design Features
********************************************************************************
********************************************************************************
use "Data/achievement_data.dta", clear

collapse (max) student_data studentsurvey feedback fireteachers informpd bonuses careerladder grantstenure multiplecategories observationsareexplicitlyrequire, by(fips)

collapse (sum) student_data studentsurvey feedback fireteachers informpd bonuses careerladder grantstenure multiplecategories observationsareexplicitlyrequire

order fireteachers grantstenure bonuses careerladder multiplecategories ///
	observationsareexplicitlyrequire studentsurvey student_data feedback informpd
	
mkmat fireteachers-informpd, mat(policies)
mat policies=policies'

putexcel set "Output/appendix_table_b1_teacher_eval_design_reforms.xlsx", modify
putexcel C5=matrix(policies)

putexcel B4="Count"
putexcel C4="Policy"
putexcel B5="Fire Teachers"
putexcel B6="Grant Tenure"
putexcel B7="Bonus"
putexcel B8="Career Ladder"
putexcel B9="Multiple Categories"
putexcel B10="Observations Required"
putexcel B11="Student Survey"
putexcel B12="Student data"
putexcel B13="Feedback Required"
putexcel B14="Inform PD"

********************************************************************************
********************************************************************************
**# APPENDIX TABLE B.2- State Teacher Evaluation Feature Measures by State
********************************************************************************
********************************************************************************
use "Data/achievement_data.dta", clear
drop if stateabb==""
collapse (max) gen_st_tch_eval_imp measurement_min1 incent_acct_min1 feedback_all index, by(stateabb)

mkmat gen_st_tch_eval_imp measurement_min1 incent_acct_min1 feedback_all index, mat(components)

putexcel set "Output/appendix_table_b2_teacher_eval_feature_measures_by_state", modify
putexcel C3=matrix(components)

putexcel C2="State"
putexcel D2="Ever Adopted"
putexcel E2="Measurement"
putexcel F2="Accountability/Incentive"
putexcel G2="Feedback/PD Index"

********************************************************************************
********************************************************************************
**# APPENDIX TABLE B.3- Teacher Evaluation Categorical Constructs and Quality Measures
********************************************************************************
use "Data/achievement_data.dta", clear
drop if stateabb==""

putexcel set "Output/appendix_table_b3_teacher_eval_categories_qual_measures", modify

unique stateabb if measurement_min1==1
	mat catqal=r(unique)
	putexcel C3=matrix(catqal)
unique stateabb if incent_acct_min1==1
	mat catqal=r(unique)
	putexcel C4=matrix(catqal)
unique stateabb if feedback_all==1
	mat catqal=r(unique)
	putexcel C5=matrix(catqal)
unique stateabb if low_qual==1
	mat catqal=r(unique)
	putexcel C6=matrix(catqal)
unique stateabb if med_qual_v1==1
	mat catqal=r(unique)
	putexcel C7=matrix(catqal)
unique stateabb if high_qual_7==1
	mat catqal=r(unique)
	putexcel C8=matrix(catqal)

putexcel C2="Count"
putexcel B2="Category"
putexcel B3="Measurement"
putexcel B4="Accountability/Incentive"
putexcel B5="Feedback/PD Index"
putexcel B6="Low Quality"
putexcel B7="Medium Quality"
putexcel B8="High Quality"

********************************************************************************
********************************************************************************
**# Footnote 12-Wild Card Variances
********************************************************************************
********************************************************************************
use "Data/achievement_data.dta", clear

//Math
areg cs_mn_all gen_st_tch_eval_imp i.year i.grade if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid) cluster(fips)
boottest gen_st_tch_eval_imp, boottype(wild) nograph

//ELA
areg cs_mn_all gen_st_tch_eval_imp i.year i.grade if subject=="rla" & st_trim_sample==1 & st_ela_smp==1, absorb(leaid) cluster(fips)
boottest gen_st_tch_eval_imp, boottype(wild) nograph

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l totenrl_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

//Math
areg cs_mn_all gen_st_tch_eval_imp `cov' `ses_cov' `ach' i.year i.grade if subject=="mth" & st_trim_sample==1 & st_math_smp==1, absorb(leaid) cluster(fips)
boottest gen_st_tch_eval_imp, boottype(wild) nograph

//ELA
areg cs_mn_all gen_st_tch_eval_imp `cov' `ses_cov' `ach' i.year i.grade if subject=="rla" & st_trim_sample==1  & st_ela_smp==1, absorb(leaid) cluster(fips)
boottest gen_st_tch_eval_imp, boottype(wild) nograph

********************************************************************************
********************************************************************************
**# Footnote 14-Robustness to Frequency Weights
********************************************************************************
********************************************************************************
//Achievement
use "Data/achievement_data.dta", clear

//Math
qui reghdfe cs_mn_all gen_st_tch_eval_imp  if subject=="mth" & st_trim_sample==1 & st_math_smp==1 [aw=totenrl], absorb(leaid year grade) cluster(fips)
estimate store twfe_st_math
//ELA
qui reghdfe cs_mn_all gen_st_tch_eval_imp  if subject=="rla" & st_trim_sample==1 & st_ela_smp==1 [aw=totenrl], absorb(leaid year grade) cluster(fips)
estimate store twfe_st_ela

local cov perblk_base_09_l perhsp_base_09_l perind_base_09_l ///
	      perasn_base_09_l urban_base_09_l  ///
		  ppe_inst_base_09_l stud_tch_ratio_base_09_l
local ses_cov  gdp_base_09_l povertyall_base_09_l unempall_base_09_l
local ach cs_mn_all_base_09_math_imp_l cs_mn_all_base_09_ela_imp_l

//Math
qui reghdfe cs_mn_all gen_st_tch_eval_imp `cov' `ses_cov' `ach'  if subject=="mth" & st_trim_sample==1 & st_math_smp==1 [aw=totenrl], absorb(leaid year grade) cluster(fips)
estimate store twfe_pach_st_math
di r(table)[6,1] //Upper CI

//ELA
qui reghdfe cs_mn_all gen_st_tch_eval_imp `cov' `ses_cov' `ach'  if subject=="rla" & st_trim_sample==1  & st_ela_smp==1 [aw=totenrl], absorb(leaid year grade) cluster(fips)
estimate store twfe_pach_st_ela
di r(table)[6,1] //Upper CI

//Attainment
use "Data/attainment_data.dta", clear

local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l urban_l gdp_st_l hs_no_ged_a20_base_l ela_sd_naep_l math_sd_naep_l
qui reghdfe hs_no_ged_a20 gen_st_tch_eval_imp if hs_grad_a20_smp==1 & trim_sample==0 [aw=tot_enrl], absorb(fips year)  cluster(fips)
	estimate store hs_no_ged_a20_did
qui reghdfe hs_no_ged_a20 gen_st_tch_eval_imp `covars' if hs_grad_a20_smp==1 & trim_sample==0 [aw=tot_enrl], absorb(fips year)  cluster(fips)
	estimate store hs_no_ged_a20_did_covar
di r(table)[6,1] //Upper CI

local covars frpl_pct_l black_pct_l hisp_pct_l ppe_l unemp_l urban_l gdp_st_l enroll_pct_a22_base_l ela_sd_naep_l math_sd_naep_l
qui reghdfe enroll_pct_a22 gen_st_tch_eval_imp if enroll_pct_a22_smp==1 & trim_sample==0 [aw=tot_enrl], absorb(fips year) cluster(fips)
	estimate store enroll_pct_a22_did
qui reghdfe enroll_pct_a22 gen_st_tch_eval_imp `covars' if enroll_pct_a22_smp==1 & trim_sample==0 [aw=tot_enrl], absorb(fips year) cluster(fips)
	estimate store enroll_pct_a22_did_covar
di r(table)[6,1] //Upper CI
